1
0
Fork 0

Pass redirect count using options

Removing the risk it might be preserved between requests.
pull/4783/head
Chris Smith 2016-01-17 21:33:55 +00:00
parent e830a611ec
commit 33471e389f
1 changed files with 11 additions and 6 deletions

View File

@ -38,7 +38,7 @@ class RemoteFilesystem
private $lastHeaders;
private $storeAuth;
private $degradedMode = false;
private $redirects = 0;
private $redirects;
private $maxRedirects = 20;
/**
@ -208,6 +208,7 @@ class RemoteFilesystem
$this->lastProgress = null;
$this->retryAuthFailure = true;
$this->lastHeaders = array();
$this->redirects = 1; // The first request counts.
// capture username/password from URL if there is one
if (preg_match('{^https?://(.+):(.+)@([^/]+)}i', $fileUrl, $match)) {
@ -220,6 +221,12 @@ class RemoteFilesystem
unset($additionalOptions['retry-auth-failure']);
}
if (isset($additionalOptions['redirects'])) {
$this->redirects = $additionalOptions['redirects'];
unset($additionalOptions['redirects']);
}
$options = $this->getOptionsForUrl($originUrl, $additionalOptions);
$userlandFollow = isset($options['http']['follow_location']) && !$options['http']['follow_location'];
@ -351,12 +358,10 @@ class RemoteFilesystem
$this->io->writeError(sprintf('Following redirect (%u)', $this->redirects));
}
$additionalOptions['redirects'] = $this->redirects;
// TODO: Not so sure about preserving origin here...
$result = $this->get($this->originUrl, $targetUrl, $additionalOptions, $this->fileName, $this->progress);
$this->redirects--;
return $result;
return $this->get($this->originUrl, $targetUrl, $additionalOptions, $this->fileName, $this->progress);
}
if (!$this->retry) {