1
0
Fork 0

Add debug info for http status code 0

pull/9519/head
Jordi Boggiano 2020-11-25 12:37:21 +01:00
parent 47672a73c0
commit 8030fbc4ae
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 8 additions and 3 deletions

View File

@ -279,17 +279,18 @@ class CurlDownloader
while ($progress = curl_multi_info_read($this->multiHandle)) { while ($progress = curl_multi_info_read($this->multiHandle)) {
$curlHandle = $progress['handle']; $curlHandle = $progress['handle'];
$result = $progress['result'];
$i = (int) $curlHandle; $i = (int) $curlHandle;
if (!isset($this->jobs[$i])) { if (!isset($this->jobs[$i])) {
continue; continue;
} }
$progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo); $progress = curl_getinfo($curlHandle);
$job = $this->jobs[$i]; $job = $this->jobs[$i];
unset($this->jobs[$i]); unset($this->jobs[$i]);
curl_multi_remove_handle($this->multiHandle, $curlHandle);
$error = curl_error($curlHandle); $error = curl_error($curlHandle);
$errno = curl_errno($curlHandle); $errno = curl_errno($curlHandle);
curl_multi_remove_handle($this->multiHandle, $curlHandle);
curl_close($curlHandle); curl_close($curlHandle);
$headers = null; $headers = null;
@ -297,12 +298,16 @@ class CurlDownloader
$response = null; $response = null;
try { try {
// TODO progress // TODO progress
if (CURLE_OK !== $errno || $error) { if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
$errno = $errno ?: $result;
if (!$error && function_exists('curl_strerror')) { if (!$error && function_exists('curl_strerror')) {
$error = curl_strerror($errno); $error = curl_strerror($errno);
} }
throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error); throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
} }
if ($progress['http_code'] === 0) {
throw new \LogicException('Received unexpected http status code 0 without error for '.Url::sanitize($progress['url']).': '.var_export($progress, true));
}
$statusCode = $progress['http_code']; $statusCode = $progress['http_code'];
rewind($job['headerHandle']); rewind($job['headerHandle']);