File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class Client
1818 protected $ _protocol ;
1919 protected $ _login ;
2020 protected $ _password ;
21+ protected $ _proxy = '' ;
2122 protected $ _secretKey ;
2223 protected $ _version = '' ;
2324
@@ -64,6 +65,16 @@ public function setSecretKey($secretKey)
6465 $ this ->_secretKey = $ secretKey ;
6566 }
6667
68+ /**
69+ * Set proxy server for requests
70+ *
71+ * @param string $proxy
72+ */
73+ public function setProxy ($ proxy )
74+ {
75+ $ this ->_proxy = $ proxy ;
76+ }
77+
6778 /**
6879 * Set default version for requests.
6980 *
@@ -188,6 +199,10 @@ private function _performHttpRequest($request)
188199 curl_setopt ($ curl , CURLOPT_HTTPHEADER , $ this ->_getHeaders ());
189200 curl_setopt ($ curl , CURLOPT_POSTFIELDS , $ request );
190201
202+ if ('' !== $ this ->_proxy ) {
203+ curl_setopt ($ curl , CURLOPT_PROXY , $ this ->_proxy );
204+ }
205+
191206 $ result = curl_exec ($ curl );
192207
193208 if (false === $ result ) {
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ public static function setUpBeforeClass(): void
2727
2828 static ::$ _client = new \PleskX \Api \Client ($ host , $ port , $ scheme );
2929 static ::$ _client ->setCredentials ($ login , $ password );
30+
31+ if ($ proxy = getenv ('REMOTE_PROXY ' )) {
32+ static ::$ _client ->setProxy ($ proxy );
33+ }
3034 }
3135
3236 public static function tearDownAfterClass (): void
You can’t perform that action at this time.
0 commit comments