Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Symfony/Component/HttpClient/CurlHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ private static function acceptPushForRequest(string $method, array $options, Pus
}
}

return true;
$statusCode = $pushedResponse->response->getInfo('http_code') ?: 200;

return $statusCode < 300 || 400 <= $statusCode;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/HttpClient/Response/CurlResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &
$info['peer_certificate_chain'] = array_map('openssl_x509_read', array_column($certinfo, 'Cert'));
}

if (300 <= $info['http_code'] && $info['http_code'] < 400) {
if (300 <= $info['http_code'] && $info['http_code'] < 400 && null !== $options) {
if (curl_getinfo($ch, \CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) {
curl_setopt($ch, \CURLOPT_FOLLOWLOCATION, false);
} elseif (303 === $info['http_code'] || ('POST' === $info['http_method'] && \in_array($info['http_code'], [301, 302], true))) {
Expand All @@ -418,7 +418,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &

$info['redirect_url'] = null;

if (300 <= $statusCode && $statusCode < 400 && null !== $location) {
if (300 <= $statusCode && $statusCode < 400 && null !== $location && null !== $options) {
if ($noContent = 303 === $statusCode || ('POST' === $info['http_method'] && \in_array($statusCode, [301, 302], true))) {
$info['http_method'] = 'HEAD' === $info['http_method'] ? 'HEAD' : 'GET';
curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, $info['http_method']);
Expand All @@ -433,7 +433,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array &

if (401 === $statusCode && isset($options['auth_ntlm']) && 0 === strncasecmp($headers['www-authenticate'][0] ?? '', 'NTLM ', 5)) {
// Continue with NTLM auth
} elseif ($statusCode < 300 || 400 <= $statusCode || null === $location || curl_getinfo($ch, \CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) {
} elseif ($statusCode < 300 || 400 <= $statusCode || null === $location || null === $options || curl_getinfo($ch, \CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) {
// Headers and redirects completed, time to get the response's content
$multi->handlesActivity[$id][] = new FirstChunk();

Expand Down
Loading