Skip to content

Commit

Permalink
Add option to override HTTP version in CurlClient
Browse files Browse the repository at this point in the history
  • Loading branch information
spvickers committed Jun 7, 2022
1 parent 18b4df4 commit 32f51da
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Http/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
class CurlClient implements ClientInterface
{

/**
* The HTTP version tp be used.
*
* @var int $httpVersion
*/
public static $httpVersion = null;

/**
* Send the request to the target URL.
*
Expand Down Expand Up @@ -41,6 +48,9 @@ public function send(HttpMessage $message)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HEADER, true);
if (!empty(self::$httpVersion)) {
curl_setopt($ch, CURLOPT_HTTP_VERSION, self::$httpVersion);
}
$chResp = curl_exec($ch);
$message->requestHeaders = trim(str_replace("\r\n", "\n", curl_getinfo($ch, CURLINFO_HEADER_OUT)));
$chResp = str_replace("\r\n", "\n", $chResp);
Expand Down

0 comments on commit 32f51da

Please sign in to comment.