Pass redirect count using options
Removing the risk it might be preserved between requests.pull/4783/head
parent
e830a611ec
commit
33471e389f
|
@ -38,7 +38,7 @@ class RemoteFilesystem
|
||||||
private $lastHeaders;
|
private $lastHeaders;
|
||||||
private $storeAuth;
|
private $storeAuth;
|
||||||
private $degradedMode = false;
|
private $degradedMode = false;
|
||||||
private $redirects = 0;
|
private $redirects;
|
||||||
private $maxRedirects = 20;
|
private $maxRedirects = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,6 +208,7 @@ class RemoteFilesystem
|
||||||
$this->lastProgress = null;
|
$this->lastProgress = null;
|
||||||
$this->retryAuthFailure = true;
|
$this->retryAuthFailure = true;
|
||||||
$this->lastHeaders = array();
|
$this->lastHeaders = array();
|
||||||
|
$this->redirects = 1; // The first request counts.
|
||||||
|
|
||||||
// capture username/password from URL if there is one
|
// capture username/password from URL if there is one
|
||||||
if (preg_match('{^https?://(.+):(.+)@([^/]+)}i', $fileUrl, $match)) {
|
if (preg_match('{^https?://(.+):(.+)@([^/]+)}i', $fileUrl, $match)) {
|
||||||
|
@ -220,6 +221,12 @@ class RemoteFilesystem
|
||||||
unset($additionalOptions['retry-auth-failure']);
|
unset($additionalOptions['retry-auth-failure']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($additionalOptions['redirects'])) {
|
||||||
|
$this->redirects = $additionalOptions['redirects'];
|
||||||
|
|
||||||
|
unset($additionalOptions['redirects']);
|
||||||
|
}
|
||||||
|
|
||||||
$options = $this->getOptionsForUrl($originUrl, $additionalOptions);
|
$options = $this->getOptionsForUrl($originUrl, $additionalOptions);
|
||||||
$userlandFollow = isset($options['http']['follow_location']) && !$options['http']['follow_location'];
|
$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));
|
$this->io->writeError(sprintf('Following redirect (%u)', $this->redirects));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$additionalOptions['redirects'] = $this->redirects;
|
||||||
|
|
||||||
// TODO: Not so sure about preserving origin here...
|
// TODO: Not so sure about preserving origin here...
|
||||||
$result = $this->get($this->originUrl, $targetUrl, $additionalOptions, $this->fileName, $this->progress);
|
return $this->get($this->originUrl, $targetUrl, $additionalOptions, $this->fileName, $this->progress);
|
||||||
|
|
||||||
$this->redirects--;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->retry) {
|
if (!$this->retry) {
|
||||||
|
|
Loading…
Reference in New Issue