Skip to content

Commit cf4fecb

Browse files
committed
feat: support CURL HTTP3
1 parent f7c471d commit cf4fecb

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

system/HTTP/CURLRequest.php

+6
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,12 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
658658
$curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
659659
} elseif ($version === '2.0') {
660660
$curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
661+
} elseif ($version === '3.0') {
662+
if (! defined('CURL_HTTP_VERSION_3')) {
663+
define('CURL_HTTP_VERSION_3', 30);
664+
}
665+
666+
$curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_3;
661667
}
662668
}
663669

tests/system/HTTP/CURLRequestTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,18 @@ public function testHTTPv2(): void
11561156
$this->assertSame(CURL_HTTP_VERSION_2_0, $options[CURLOPT_HTTP_VERSION]);
11571157
}
11581158

1159+
public function testHTTPv3(): void
1160+
{
1161+
$this->request->request('POST', '/post', [
1162+
'version' => 3.0,
1163+
]);
1164+
1165+
$options = $this->request->curl_options;
1166+
1167+
$this->assertArrayHasKey(CURLOPT_HTTP_VERSION, $options);
1168+
$this->assertSame(CURL_HTTP_VERSION_3, $options[CURLOPT_HTTP_VERSION]);
1169+
}
1170+
11591171
public function testCookieOption(): void
11601172
{
11611173
$holder = SUPPORTPATH . 'HTTP/Files/CookiesHolder.txt';

0 commit comments

Comments
 (0)