fix: [curlclient] HEAD failing

- added CURLOPT_NOBODY for HEAD requests, as described in https://www.php.net/manual/en/function.curl-setopt.php
pull/9636/head
iglocska 2024-03-22 15:04:57 +01:00
parent 544a450fea
commit fed7149e93
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 4 additions and 1 deletions

View File

@ -202,6 +202,10 @@ class CurlClient extends HttpSocketExtended
$options[CURLOPT_POSTFIELDS] = $query; $options[CURLOPT_POSTFIELDS] = $query;
} }
if ($method === 'HEAD') {
$options[CURLOPT_NOBODY] = true;
}
if (!empty($request['header'])) { if (!empty($request['header'])) {
$headers = []; $headers = [];
foreach ($request['header'] as $key => $value) { foreach ($request['header'] as $key => $value) {
@ -231,7 +235,6 @@ class CurlClient extends HttpSocketExtended
} }
return $len; return $len;
}; };
if (!curl_setopt_array($this->ch, $options)) { if (!curl_setopt_array($this->ch, $options)) {
throw new \RuntimeException('curl error: Could not set options'); throw new \RuntimeException('curl error: Could not set options');
} }