Skip to content

Commit 4a8c4ee

Browse files
author
NASSAR Mohammed (DIGIT-EXT)
committed
Add proxy support for array configs on curl request
1 parent 13f825c commit 4a8c4ee

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

src/Configuration/AbstractConfiguration.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,34 @@ abstract class AbstractConfiguration implements ConfigurationInterface
9191
*/
9292
protected $cookieFile;
9393

94+
/**
95+
* Proxy server.
96+
*
97+
* @var string
98+
*/
99+
protected $proxyServer;
100+
101+
/**
102+
* Proxy port.
103+
*
104+
* @var string
105+
*/
106+
protected $proxyPort;
107+
108+
/**
109+
* Proxy user.
110+
*
111+
* @var string
112+
*/
113+
protected $proxyUser;
114+
115+
/**
116+
* Proxy password.
117+
*
118+
* @var string
119+
*/
120+
protected $proxyPassword;
121+
94122
/**
95123
* @return string
96124
*/
@@ -200,4 +228,36 @@ public function getCookieFile()
200228
{
201229
return $this->cookieFile;
202230
}
231+
232+
/**
233+
* @return string
234+
*/
235+
public function getProxyServer()
236+
{
237+
return $this->proxyServer;
238+
}
239+
240+
/**
241+
* @return string
242+
*/
243+
public function getProxyPort()
244+
{
245+
return $this->proxyPort;
246+
}
247+
248+
/**
249+
* @return string
250+
*/
251+
public function getProxyUser()
252+
{
253+
return $this->proxyUser;
254+
}
255+
256+
/**
257+
* @return string
258+
*/
259+
public function getProxyPassword()
260+
{
261+
return $this->proxyPassword;
262+
}
203263
}

src/Configuration/ConfigurationInterface.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,32 @@ public function isCookieAuthorizationEnabled();
9696
* @return mixed
9797
*/
9898
public function getCookieFile();
99+
100+
/**
101+
* Proxy server.
102+
*
103+
* @return string
104+
*/
105+
public function getProxyServer();
106+
107+
/**
108+
* Proxy port.
109+
*
110+
* @return string
111+
*/
112+
public function getProxyPort();
113+
114+
/**
115+
* Proxy user.
116+
*
117+
* @return string
118+
*/
119+
public function getProxyUser();
120+
121+
/**
122+
* Proxy password.
123+
*
124+
* @return string
125+
*/
126+
public function getProxyPassword();
99127
}

src/JiraClient.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,16 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
208208

209209
curl_setopt($ch, CURLOPT_VERBOSE, $this->getConfiguration()->isCurlOptVerbose());
210210

211+
// Add proxy settings to the curl.
212+
if ($this->getConfiguration()->getProxyServer()) {
213+
curl_setopt($ch, CURLOPT_PROXY, $this->getConfiguration()->getProxyServer());
214+
curl_setopt($ch, CURLOPT_PROXYPORT, $this->getConfiguration()->getProxyPort());
215+
216+
$username = $this->getConfiguration()->getProxyUser();
217+
$password = $this->getConfiguration()->getProxyPassword();
218+
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "$username:$password");
219+
}
220+
211221
$this->log->addDebug('Curl exec='.$url);
212222
$response = curl_exec($ch);
213223

0 commit comments

Comments
 (0)