8000 bug #35005 [HttpClient] force HTTP/1.1 when NTLM auth is used (nicola… · symfony/symfony@cb96f14 · GitHub
[go: up one dir, main page]

Skip to content

Commit cb96f14

Browse files
bug #35005 [HttpClient] force HTTP/1.1 when NTLM auth is used (nicolas-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
2 parents 3efdd80 + 0e87e9b commit cb96f14

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,17 @@ public function request(string $method, string $url, array $options = []): Respo
158158
CURLOPT_CERTINFO => $options['capture_peer_cert_chain'],
159159
];
160160

161+
if (1.0 === (float) $options['http_version']) {
162+
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
163+
} elseif (1.1 === (float) $options['http_version'] || 'https:' !== $scheme) {
164+
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
165+
} elseif (\defined('CURL_VERSION_HTTP2') && CURL_VERSION_HTTP2 & self::$curlVersion['features']) {
166+
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
167+
}
168+
161169
if (isset($options['auth_ntlm'])) {
162170
$curlopts[CURLOPT_HTTPAUTH] = CURLAUTH_NTLM;
171+
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
163172

164173
if (\is_array($options['auth_ntlm'])) {
165174
$count = \count($options['auth_ntlm']);
@@ -212,14 +221,6 @@ public function request(string $method, string $url, array $options = []): Respo
212221
$curlopts[CURLOPT_RESOLVE] = $resolve;
213222
}
214223

215-
if (1.0 === (float) $options['http_version']) {
216-
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
217-
} elseif (1.1 === (float) $options['http_version'] || 'https:' !== $scheme) {
218-
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
219-
} elseif (\defined('CURL_VERSION_HTTP2') && CURL_VERSION_HTTP2 & self::$curlVersion['features']) {
220-
$curlopts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0;
221-
}
222-
223224
if ('POST' === $method) {
224225
// Use CURLOPT_POST to have browser-like POST-to-GET redirects for 301, 302 and 303
225226
$curlopts[CURLOPT_POST] = true;

0 commit comments

Comments
 (0)
0