Skip to content

Commit 1f749c1

Browse files
committed
Merge pull request #332 from Awnage/master
Add ability to use a proxy.
2 parents c75a941 + 93a5279 commit 1f749c1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Geocoder/HttpAdapter/CurlHttpAdapter.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ class CurlHttpAdapter implements HttpAdapterInterface
2222
private $connectTimeout;
2323

2424
private $userAgent;
25+
26+
/**
27+
* Array for bulk setting of curl options
28+
* @see http://php.net/manual/en/curl.constants.php
29+
* @var array
30+
*/
31+
private $options;
2532

26-
public function __construct($timeout = null, $connectTimeout = null, $userAgent = null)
33+
public function __construct($timeout = null, $connectTimeout = null, $userAgent = null, $options = array())
2734
{
2835
$this->timeout = $timeout;
2936
$this->connectTimeout = $connectTimeout;
3037
$this->userAgent = $userAgent;
38+
$this->options = $options;
3139
}
3240

3341
/**
@@ -55,6 +63,10 @@ public function getContent($url)
5563
curl_setopt($c, CURLOPT_USERAGENT, $this->userAgent);
5664
}
5765

66+
if ($this->options && is_array($this->options) && count($this->options)>0) {
67+
curl_setopt_array($c, $this->options);
68+
}
69+
5870
$content = curl_exec($c);
5971
curl_close($c);
6072

0 commit comments

Comments
 (0)