diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index dadc1eff34ea..92ab3946b90c 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -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; } } diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index f14198be2264..32415c86d3ee 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -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';