Skip to content

Commit

Permalink
bug #37484 [HttpClient][CurlHttpClient] Fix http_version option usage…
Browse files Browse the repository at this point in the history
… (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient][CurlHttpClient] Fix http_version option usage

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37402
| License       | MIT
| Doc PR        | -

Ref #36422

If the scheme is https, we should only set http version 2.0 if the http_version is not specified.

Commits
-------

2676902 [HttpClient][CurlHttpClient] Fix http_version option usage
  • Loading branch information
nicolas-grekas committed Jul 3, 2020
2 parents 659699b + 2676902 commit f024382
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/HttpClient/CurlHttpClient.php
Expand Up @@ -138,12 +138,12 @@ public function request(string $method, string $url, array $options = []): Respo
CURLOPT_CERTINFO => $options['capture_peer_cert_chain'],
];

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']) {
if (1.0 === (float) $options['http_version']) {
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
} 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']) && ('https:' === $scheme || 2.0 === (float) $options['http_version'])) {
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
}

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

0 comments on commit f024382

Please sign in to comment.