|
28 | 28 | */ |
29 | 29 | class RpcConnector |
30 | 30 | { |
| 31 | + const COOKIE_FILE = '/tmp/proxyidp_cookie.txt'; |
| 32 | + const CONNECT_TIMEOUT = 1; |
| 33 | + const TIMEOUT = 15; |
| 34 | + |
31 | 35 | private $rpcUrl; |
32 | 36 | private $user; |
33 | 37 | private $password; |
@@ -57,6 +61,10 @@ public function get($manager, $method, $params = []) |
57 | 61 | curl_setopt($ch, CURLOPT_URL, $uri . '?' . $paramsQuery); |
58 | 62 | curl_setopt($ch, CURLOPT_USERPWD, $this->user . ":" . $this->password); |
59 | 63 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 64 | + curl_setopt($ch, CURLOPT_COOKIEJAR, self::COOKIE_FILE); |
| 65 | + curl_setopt($ch, CURLOPT_COOKIEFILE, self::COOKIE_FILE); |
| 66 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::CONNECT_TIMEOUT); |
| 67 | + curl_setopt($ch, CURLOPT_TIMEOUT, self::TIMEOUT); |
60 | 68 |
|
61 | 69 | $json = curl_exec($ch); |
62 | 70 | curl_close($ch); |
@@ -94,6 +102,10 @@ public function post($manager, $method, $params = []) |
94 | 102 | ['Content-Type:application/json', 'Content-Length: ' . strlen($paramsJson)] |
95 | 103 | ); |
96 | 104 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 105 | + curl_setopt($ch, CURLOPT_COOKIEJAR, self::COOKIE_FILE); |
| 106 | + curl_setopt($ch, CURLOPT_COOKIEFILE, self::COOKIE_FILE); |
| 107 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::CONNECT_TIMEOUT); |
| 108 | + curl_setopt($ch, CURLOPT_TIMEOUT, self::TIMEOUT); |
97 | 109 |
|
98 | 110 | $json = curl_exec($ch); |
99 | 111 | curl_close($ch); |
|
0 commit comments