Skip to content

Commit c05260c

Browse files
authored
Merge pull request #9145 from ddevsr/CURL-CONSTANT
feat: support CURL HTTP3
2 parents d005c44 + 484c311 commit c05260c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-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

+16
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,22 @@ 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+
if (! defined('CURL_HTTP_VERSION_3')) {
1168+
define('CURL_HTTP_VERSION_3', 30);
1169+
}
1170+
1171+
$this->assertArrayHasKey(CURLOPT_HTTP_VERSION, $options);
1172+
$this->assertSame(CURL_HTTP_VERSION_3, $options[CURLOPT_HTTP_VERSION]);
1173+
}
1174+
11591175
public function testCookieOption(): void
11601176
{
11611177
$holder = SUPPORTPATH . 'HTTP/Files/CookiesHolder.txt';

0 commit comments

Comments
 (0)