From 8030fbc4aeed57cd54c89ece23c79641ca808775 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 25 Nov 2020 12:37:21 +0100 Subject: [PATCH] Add debug info for http status code 0 --- src/Composer/Util/Http/CurlDownloader.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Composer/Util/Http/CurlDownloader.php b/src/Composer/Util/Http/CurlDownloader.php index 2d1d1a3f0..4d79582d6 100644 --- a/src/Composer/Util/Http/CurlDownloader.php +++ b/src/Composer/Util/Http/CurlDownloader.php @@ -279,17 +279,18 @@ class CurlDownloader while ($progress = curl_multi_info_read($this->multiHandle)) { $curlHandle = $progress['handle']; + $result = $progress['result']; $i = (int) $curlHandle; if (!isset($this->jobs[$i])) { continue; } - $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo); + $progress = curl_getinfo($curlHandle); $job = $this->jobs[$i]; unset($this->jobs[$i]); - curl_multi_remove_handle($this->multiHandle, $curlHandle); $error = curl_error($curlHandle); $errno = curl_errno($curlHandle); + curl_multi_remove_handle($this->multiHandle, $curlHandle); curl_close($curlHandle); $headers = null; @@ -297,12 +298,16 @@ class CurlDownloader $response = null; try { // TODO progress - if (CURLE_OK !== $errno || $error) { + if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) { + $errno = $errno ?: $result; if (!$error && function_exists('curl_strerror')) { $error = curl_strerror($errno); } 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']; rewind($job['headerHandle']);