Skip to content

Commit adb7846

Browse files
committed
Merge pull request #326 from siad007/patch-1
Curl needs the abillity to set a custom user agent with nominatim
2 parents c2d9919 + 992b743 commit adb7846

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Geocoder/HttpAdapter/CurlHttpAdapter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ class CurlHttpAdapter implements HttpAdapterInterface
2121

2222
private $connectTimeout;
2323

24-
public function __construct($timeout = null, $connectTimeout = null)
24+
private $userAgent;
25+
26+
public function __construct($timeout = null, $connectTimeout = null, $userAgent = null)
2527
{
2628
$this->timeout = $timeout;
2729
$this->connectTimeout = $connectTimeout;
30+
$this->userAgent = $userAgent;
2831
}
2932

3033
/**
@@ -47,6 +50,10 @@ public function getContent($url)
4750
if ($this->connectTimeout) {
4851
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
4952
}
53+
54+
if ($this->userAgent) {
55+
curl_setopt($c, CURLOPT_USERAGENT, $this->userAgent);
56+
}
5057

5158
$content = curl_exec($c);
5259
curl_close($c);

0 commit comments

Comments
 (0)