From 906563451ea14212584842e72c3bf1f02f13fa82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= Date: Tue, 5 Mar 2013 13:34:48 +0100 Subject: [PATCH] Reverted the last changes. Changed logic in callbackGet() method to respect the 401 handling also if STREAM_NOTIFY_FAILURE fires as on my local machine the handling of STREAM_NOTIFY_AUTH_REQUIRED never got executed. --- src/Composer/Util/RemoteFilesystem.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index db41bdcfa..d1161a3db 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -125,18 +125,6 @@ class RemoteFilesystem if ($e instanceof TransportException && !empty($http_response_header[0])) { $e->setHeaders($http_response_header); } - - // in case the remote filesystem responds with an 401 error ask for credentials - if($e instanceof TransportException && ($e->getCode() == 401)) - { - $this->io->write('Enter the access credentials needed to access the resource at '.$originUrl); - $username = $this->io->ask('Username: '); - $password = $this->io->askAndHideAnswer('Password: '); - $this->io->setAuthentication($originUrl, $username, $password); - - // try getting the file again - return $this->get($originUrl, $fileUrl, $additionalOptions, $fileName, $progress); - } } if ($errorMessage && !ini_get('allow_url_fopen')) { $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')'; @@ -223,9 +211,6 @@ class RemoteFilesystem { switch ($notificationCode) { case STREAM_NOTIFY_FAILURE: - throw new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.trim($message).')', $messageCode); - break; - case STREAM_NOTIFY_AUTH_REQUIRED: if (401 === $messageCode) { if (!$this->io->isInteractive()) { @@ -240,7 +225,10 @@ class RemoteFilesystem $this->io->setAuthentication($this->originUrl, $username, $password); $this->get($this->originUrl, $this->fileUrl, $this->fileName, $this->progress); + break; } + + throw new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.trim($message).')', $messageCode); break; case STREAM_NOTIFY_AUTH_RESULT: