HttpDriver.php: add headers to requestGet

This commit is contained in:
Zankaria 2025-03-16 22:52:28 +01:00
parent a5cc1c2b42
commit bf42570d5d

View file

@ -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);