diff --git a/inc/Data/Driver/HttpDriver.php b/inc/Data/Driver/HttpDriver.php index 022fcbab..197f2681 100644 --- a/inc/Data/Driver/HttpDriver.php +++ b/inc/Data/Driver/HttpDriver.php @@ -38,11 +38,12 @@ class HttpDriver { * * @param string $endpoint Uri endpoint. * @param ?array $data Optional GET parameters. + * @param ?array $data Optional HTTP headers. * @param int $timeout Optional request timeout in seconds. Use the default timeout if 0. * @return string Returns the body of the response. * @throws RuntimeException Throws on IO error. */ - public function requestGet(string $endpoint, ?array $data, int $timeout = 0): string { + public function requestGet(string $endpoint, ?array $data, ?array $headers, int $timeout = 0): string { if (!empty($data)) { $endpoint .= '?' . \http_build_query($data); } @@ -51,6 +52,9 @@ class HttpDriver { } $this->resetTowards($endpoint, $timeout); + if (!empty($headers)) { + \curl_setopt($this->inner, \CURLOPT_HTTPHEADER, $headers); + } \curl_setopt($this->inner, \CURLOPT_RETURNTRANSFER, true); $ret = \curl_exec($this->inner);