Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/Jira/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ class Api
* @var array|null
*/
protected $resolutions;

/**
* Proxy to use.
*
* @var string
*/
protected $proxy;

/**
* Create a JIRA API client.
Expand All @@ -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;
Expand All @@ -115,6 +123,8 @@ public function __construct(
}

$this->client = $client;

$this->proxy = $proxy;
}

/**
Expand Down Expand Up @@ -723,7 +733,8 @@ public function api(
$this->getEndpoint(),
$this->authentication,
$is_file,
$debug
$debug,
$this->proxy
);

if ( strlen($result) ) {
Expand Down
9 changes: 8 additions & 1 deletion src/Jira/Api/Client/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand All @@ -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);

Expand Down