From 8a8ec6fccc1cdfed76a30080811371966df2129e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 17 Jan 2016 21:34:34 +0000 Subject: [PATCH] Too many redirects is not an error in PHP, return the latest response --- src/Composer/Util/RemoteFilesystem.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 1216761ec..82b8f400d 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -303,7 +303,7 @@ class RemoteFilesystem $statusCode = $this->findStatusCode($http_response_header); } - if ($userlandFollow && !empty($http_response_header[0]) && preg_match('{^HTTP/\S+ (3\d\d)}i', $http_response_header[0], $match)) { + if ($userlandFollow && !empty($http_response_header[0]) && preg_match('{^HTTP/\S+ (3\d\d)}i', $http_response_header[0], $match) && $this->redirects < $this->maxRedirects) { foreach ($http_response_header as $header) { if (preg_match('{^location: *(.+) *$}i', $header, $m)) { if (parse_url($m[1], PHP_URL_SCHEME)) { @@ -337,13 +337,6 @@ class RemoteFilesystem if ($targetUrl) { $this->redirects++; - if ($this->redirects > $this->maxRedirects) { - $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, too many redirects'); - $e->setHeaders($http_response_header); - $e->setResponse($result); - throw $e; - } - // TODO: Disabled because this is (probably) different behaviour to PHP following for us. // if ('http' === parse_url($targetUrl, PHP_URL_SCHEME) && 'https' === $this->scheme) { // // Do not allow protocol downgrade.