Skip to content

Commit

Permalink
bug #35005 [HttpClient] force HTTP/1.1 when NTLM auth is used (nicola…
Browse files Browse the repository at this point in the history
…s-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpClient] force HTTP/1.1 when NTLM auth is used

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

NTLM requires HTTP/1.1.

Commits
-------

0e87e9b [HttpClient] force HTTP/1.1 when NTLM auth is used
  • Loading branch information
nicolas-grekas committed Dec 17, 2019
2 parents 3efdd80 + 0e87e9b commit cb96f14
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/Symfony/Component/HttpClient/CurlHttpClient.php
Expand Up @@ -158,8 +158,17 @@ public function request(string $method, string $url, array $options = []): Respo
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']);
Expand Down Expand Up @@ -212,14 +221,6 @@ public function request(string $method, string $url, array $options = []): Respo
$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;
Expand Down

0 comments on commit cb96f14

Please sign in to comment.