diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index b830986cd..6a4d68103 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -1,4 +1,5 @@ firstCall = true; $this->bytesMax = 0; - $this->content = null; - $this->originUrl = $originUrl; - $this->fileUrl = $fileUrl; + $this->content = null; + $this->originUrl = $originUrl; + $this->fileUrl = $fileUrl; $this->fileName = $fileName; - $this->progress = $progess; - + $this->progress = $progess; + // add authorization in context $options = array(); - if ($this->io->hasAuthorization($originUrl)) { + if ($this->io->hasAuthorization($originUrl)) { $auth = $this->io->getAuthorization($originUrl); $authStr = base64_encode($auth['username'] . ':' . $auth['password']); $options['http']['header'] = "Authorization: Basic $authStr\r\n"; - } else if (null !== $this->io->getLastUsername()) { - $authStr = base64_encode($this->io->getLastUsername() . ':' . $this->io->getLastPassword()); - $options['http'] = array('header' => "Authorization: Basic $authStr\r\n"); - $this->io->setAuthorization($originUrl, $this->io->getLastUsername(), $this->io->getLastPassword()); - } - - $ctx = StreamContextFactory::getContext($options, array('notification' => array($this, 'callbackGet'))); - + } else if (null !== $this->io->getLastUsername()) { + $authStr = base64_encode($this->io->getLastUsername() . ':' . $this->io->getLastPassword()); + $options['http'] = array('header' => "Authorization: Basic $authStr\r\n"); + $this->io->setAuthorization($originUrl, $this->io->getLastUsername(), $this->io->getLastPassword()); + } + + $ctx = StreamContextFactory::getContext($options, array('notification' => array($this, 'callbackGet'))); + if ($this->progress) { $this->io->overwrite(" Downloading: connection...", false); } @@ -110,8 +110,8 @@ class RemoteFilesystem } else { $result = @file_get_contents($fileUrl, false, $ctx); $this->content = $result; - } - + } + if ($this->progress) { $this->io->overwrite(" Downloading", false); }