Skip to content

Commit c571fa9

Browse files
[HttpClient] fix HTTP/2 support on non-SSL connections - CurlHttpClient only
1 parent 9a8f5c9 commit c571fa9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

CurlHttpClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ public function request(string $method, string $url, array $options = []): Respo
141141
CURLOPT_CERTINFO => $options['capture_peer_cert_chain'],
142142
];
143143

144-
if (1.0 === (float) $options['http_version']) {
144+
if (\defined('CURL_VERSION_HTTP2') && (CURL_VERSION_HTTP2 & self::$curlVersion['features']) && ('https:' === $scheme || 2.0 === (float) $options['http_version'])) {
145+
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
146+
} elseif (1.0 === (float) $options['http_version']) {
145147
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
146-
} elseif (1.1 === (float) $options['http_version'] || 'https:' !== $scheme) {
148+
} elseif (1.1 === (float) $options['http_version']) {
147149
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
148-
} elseif (\defined('CURL_VERSION_HTTP2') && CURL_VERSION_HTTP2 & self::$curlVersion['features']) {
149-
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
150150
}
151151

152152
if (isset($options['auth_ntlm'])) {

0 commit comments

Comments
 (0)