Skip to content

Commit

Permalink
adds an HTTP Header User-Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
tsamaya committed Mar 11, 2024
1 parent 0c7b72b commit 5f095c9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
3.3.0 -- Mon Mar 11 2024
=====================================================
- add an HTTP header: User-Agent

3.2.2 -- Mon Feb 26 2024
=====================================================
- add setProxy method
Expand Down Expand Up @@ -33,7 +37,6 @@
returned. file_get_contents is only used when the curl fetching doesn't
work (rare)


2.0.3 -- Sat Apr 27 2019
=====================================================
- API returns HTTP 401 for invalid key
Expand Down
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ubuntu:22.04

ENV TZ=Europe/London

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update -qq && \
apt-get install -y -qq curl vim php-cli php-curl php-xml php-mbstring unzip

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN useradd --user-group --system --create-home --no-log-init app

COPY . /usr/src/myapp
WORKDIR /usr/src/myapp

RUN chown -R app:app /usr/src/myapp

USER app

CMD ["/bin/bash"]
7 changes: 7 additions & 0 deletions src/AbstractGeocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ protected function getJSONByCurl($query)
}
curl_setopt_array($ch, $options);

$headers = [
'User-Agent: opencage-php',
];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);


$ret = curl_exec($ch);
if ($ret === false) {
return $this->generateErrorJSON(498, 'network issue '.curl_error($ch));
Expand Down

0 comments on commit 5f095c9

Please sign in to comment.