Skip to content

Commit

Permalink
[HttpClient] fix HTTP/2 support on non-SSL connections - CurlHttpClie…
Browse files Browse the repository at this point in the history
…nt only
  • Loading branch information
nicolas-grekas committed Apr 11, 2020
1 parent 9a8f5c9 commit c571fa9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CurlHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ public function request(string $method, string $url, array $options = []): Respo
CURLOPT_CERTINFO => $options['capture_peer_cert_chain'],
];

if (1.0 === (float) $options['http_version']) {
if (\defined('CURL_VERSION_HTTP2') && (CURL_VERSION_HTTP2 & self::$curlVersion['features']) && ('https:' === $scheme || 2.0 === (float) $options['http_version'])) {
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
} elseif (1.0 === (float) $options['http_version']) {
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
} elseif (1.1 === (float) $options['http_version'] || 'https:' !== $scheme) {
} elseif (1.1 === (float) $options['http_version']) {
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
} elseif (\defined('CURL_VERSION_HTTP2') && CURL_VERSION_HTTP2 & self::$curlVersion['features']) {
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
}

if (isset($options['auth_ntlm'])) {
Expand Down

0 comments on commit c571fa9

Please sign in to comment.