Too many redirects is not an error in PHP, return the latest response
parent
33471e389f
commit
8a8ec6fccc
|
@ -303,7 +303,7 @@ class RemoteFilesystem
|
||||||
$statusCode = $this->findStatusCode($http_response_header);
|
$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) {
|
foreach ($http_response_header as $header) {
|
||||||
if (preg_match('{^location: *(.+) *$}i', $header, $m)) {
|
if (preg_match('{^location: *(.+) *$}i', $header, $m)) {
|
||||||
if (parse_url($m[1], PHP_URL_SCHEME)) {
|
if (parse_url($m[1], PHP_URL_SCHEME)) {
|
||||||
|
@ -337,13 +337,6 @@ class RemoteFilesystem
|
||||||
if ($targetUrl) {
|
if ($targetUrl) {
|
||||||
$this->redirects++;
|
$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.
|
// TODO: Disabled because this is (probably) different behaviour to PHP following for us.
|
||||||
// if ('http' === parse_url($targetUrl, PHP_URL_SCHEME) && 'https' === $this->scheme) {
|
// if ('http' === parse_url($targetUrl, PHP_URL_SCHEME) && 'https' === $this->scheme) {
|
||||||
// // Do not allow protocol downgrade.
|
// // Do not allow protocol downgrade.
|
||||||
|
|
Loading…
Reference in New Issue