From 0e87e9b9604dcf5583edf44120fea616285bbd9d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 17 Dec 2019 10:59:36 +0100 Subject: [PATCH] [HttpClient] force HTTP/1.1 when NTLM auth is used --- .../Component/HttpClient/CurlHttpClient.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index 0f872dfa97..eb6dfd5fa7 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -158,8 +158,17 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, CURLOPT_CERTINFO => $options['capture_peer_cert_chain'], ]; + if (1.0 === (float) $options['http_version']) { + $curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; + } elseif (1.1 === (float) $options['http_version'] || 'https:' !== $scheme) { + $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'])) { $curlopts[CURLOPT_HTTPAUTH] = CURLAUTH_NTLM; + $curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; if (\is_array($options['auth_ntlm'])) { $count = \count($options['auth_ntlm']); @@ -212,14 +221,6 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, $curlopts[CURLOPT_RESOLVE] = $resolve; } - if (1.0 === (float) $options['http_version']) { - $curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; - } elseif (1.1 === (float) $options['http_version'] || 'https:' !== $scheme) { - $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 ('POST' === $method) { // Use CURLOPT_POST to have browser-like POST-to-GET redirects for 301, 302 and 303 $curlopts[CURLOPT_POST] = true;