From 2ba2f34b09785201a2386ad5bb4b10a9e9327295 Mon Sep 17 00:00:00 2001 From: antonito82 <35367975+antonito82@users.noreply.github.com> Date: Thu, 29 Oct 2020 10:49:48 +0100 Subject: [PATCH 1/2] feat: set a proxy to use for the request --- src/Jira/Api.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Jira/Api.php b/src/Jira/Api.php index 33f2a4e..1903b94 100644 --- a/src/Jira/Api.php +++ b/src/Jira/Api.php @@ -94,6 +94,13 @@ class Api * @var array|null */ protected $resolutions; + + /** + * Proxy to use. + * + * @var string + */ + protected $proxy; /** * Create a JIRA API client. @@ -105,7 +112,8 @@ class Api public function __construct( $endpoint, AuthenticationInterface $authentication, - ClientInterface $client = null + ClientInterface $client = null, + $proxy = null ) { $this->setEndPoint($endpoint); $this->authentication = $authentication; @@ -115,6 +123,8 @@ public function __construct( } $this->client = $client; + + $this->proxy = $proxy; } /** @@ -723,7 +733,8 @@ public function api( $this->getEndpoint(), $this->authentication, $is_file, - $debug + $debug, + $this->proxy ); if ( strlen($result) ) { From 15077eb2f0fcc732d2cb5c858d18631e0cb6c0ae Mon Sep 17 00:00:00 2001 From: antonito82 <35367975+antonito82@users.noreply.github.com> Date: Thu, 29 Oct 2020 10:51:37 +0100 Subject: [PATCH 2/2] feat: set a proxy to use for the request --- src/Jira/Api/Client/CurlClient.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Jira/Api/Client/CurlClient.php b/src/Jira/Api/Client/CurlClient.php index 9e3acb8..c445d72 100644 --- a/src/Jira/Api/Client/CurlClient.php +++ b/src/Jira/Api/Client/CurlClient.php @@ -51,6 +51,7 @@ public function __construct() * @param AuthenticationInterface $credential Credential. * @param boolean $is_file This is a file upload request. * @param boolean $debug Debug this request. + * @param string $proxy Proxy to use for the request * * @return array|string * @throws \InvalidArgumentException When non-supported implementation of AuthenticationInterface is given. @@ -66,7 +67,8 @@ public function sendRequest( $endpoint, AuthenticationInterface $credential, $is_file = false, - $debug = false + $debug = false, + $proxy = null ) { if ( !($credential instanceof Basic) && !($credential instanceof Anonymous) ) { throw new \InvalidArgumentException(sprintf( @@ -86,6 +88,11 @@ public function sendRequest( } curl_setopt($curl, CURLOPT_URL, $endpoint . $url); + + if( !is_null($proxy) ) { + curl_setopt($curl, CURLOPT_PROXY, $proxy); + } + curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);