Skip to content

Commit

Permalink
Merge pull request #9145 from ddevsr/CURL-CONSTANT
Browse files Browse the repository at this point in the history
feat: support CURL HTTP3
  • Loading branch information
kenjis authored Sep 12, 2024
2 parents d005c44 + 484c311 commit c05260c
Show file tree
Hide file tree
Showing 2 changed files with 22 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
16 changes: 16 additions & 0 deletions tests/system/HTTP/CURLRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,22 @@ 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;

if (! defined('CURL_HTTP_VERSION_3')) {
define('CURL_HTTP_VERSION_3', 30);
}

$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 c05260c

Please sign in to comment.