Skip to content

Commit

Permalink
feat: support CURL HTTP3
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr committed Sep 10, 2024
1 parent d005c44 commit 052520f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions system/HTTP/CURLRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,12 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
$curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
} elseif ($version === '2.0') {
$curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
} elseif ($version === '3.0') {
if (! defined('CURL_HTTP_VERSION_3')) {
define('CURL_HTTP_VERSION_3', 30);
}

$curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_3;
}
}

Expand Down
12 changes: 12 additions & 0 deletions tests/system/HTTP/CURLRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,18 @@ public function testHTTPv2(): void
$this->assertSame(CURL_HTTP_VERSION_2_0, $options[CURLOPT_HTTP_VERSION]);
}

public function testHTTPv3(): void
{
$this->request->request('POST', '/post', [
'version' => 3.0,
]);

$options = $this->request->curl_options;

$this->assertArrayHasKey(CURLOPT_HTTP_VERSION, $options);
$this->assertSame(CURL_HTTP_VERSION_3, $options[CURLOPT_HTTP_VERSION]);
}

public function testCookieOption(): void
{
$holder = SUPPORTPATH . 'HTTP/Files/CookiesHolder.txt';
Expand Down

0 comments on commit 052520f

Please sign in to comment.