Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 8dcac76

Browse files
Merge pull request #67 from pajavyskocil/rpc_connector_fixes
Rpc connector fixes
2 parents 3d5cef1 + 103cd44 commit 8dcac76

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
5+
#### Changed
6+
- RpcConnector now stores cookie into file
7+
- Set CONNECTTIMEOUT and TIMEOUT in RpcConnector
58

69
## [v3.2.0]
710
#### Added

lib/RpcConnector.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
*/
2929
class RpcConnector
3030
{
31+
const COOKIE_FILE = '/tmp/proxyidp_cookie.txt';
32+
const CONNECT_TIMEOUT = 1;
33+
const TIMEOUT = 15;
34+
3135
private $rpcUrl;
3236
private $user;
3337
private $password;
@@ -57,6 +61,10 @@ public function get($manager, $method, $params = [])
5761
curl_setopt($ch, CURLOPT_URL, $uri . '?' . $paramsQuery);
5862
curl_setopt($ch, CURLOPT_USERPWD, $this->user . ":" . $this->password);
5963
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);
6068

6169
$json = curl_exec($ch);
6270
curl_close($ch);
@@ -94,6 +102,10 @@ public function post($manager, $method, $params = [])
94102
['Content-Type:application/json', 'Content-Length: ' . strlen($paramsJson)]
95103
);
96104
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);
97109

98110
$json = curl_exec($ch);
99111
curl_close($ch);

0 commit comments

Comments
 (0)