Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4cccd7e

Browse files
authored
Handle empty response data correctly
curl will return -1.0 for CURLINFO_CONTENT_LENGTH_DOWNLOAD since 7.19.4 if not known (means not specified by the server response). When handling data for empty responses, this will cause us to compare 0.0 (CURLINFO_SIZE_DOWNLOAD) with -1.0 (CURLINFO_CONTENT_LENGTH_DOWNLOAD) and thus error out with SSL error 0 then (which means normal close). We therefore now explicitely allow to download 0 bytes, when no size has been indicated.
1 parent c3f10c3 commit 4cccd7e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/HttpClient/Response/CurlResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private static function perform(ClientState $multi, ?array &$responses = null):
316316
}
317317

318318
$multi->handlesActivity[$id][] = null;
319-
$multi->handlesActivity[$id][] = \in_array($result, [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || '_0' === $waitFor || curl_getinfo($ch, \CURLINFO_SIZE_DOWNLOAD) === curl_getinfo($ch, \CURLINFO_CONTENT_LENGTH_DOWNLOAD) ? null : new TransportException(ucfirst(curl_error($ch) ?: curl_strerror($result)).\sprintf(' for "%s".', curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL)));
319+
$multi->handlesActivity[$id][] = \in_array($result, [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || '_0' === $waitFor || curl_getinfo($ch, \CURLINFO_SIZE_DOWNLOAD) === curl_getinfo($ch, \CURLINFO_CONTENT_LENGTH_DOWNLOAD) || (curl_getinfo($ch, \CURLINFO_SIZE_DOWNLOAD) === 0.0 && -1.0 === curl_getinfo($ch, \CURLINFO_CONTENT_LENGTH_DOWNLOAD)) ? null : new TransportException(ucfirst(curl_error($ch) ?: curl_strerror($result)).sprintf(' for "%s".', curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL)));
320320
}
321321
} finally {
322322
$multi->performing = false;

0 commit comments

Comments
 (0)