Pārlūkot izejas kodu

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.

Stephan Hochdörfer 12 gadi atpakaļ
vecāks
revīzija
906563451e
1 mainītis faili ar 3 papildinājumiem un 15 dzēšanām
  1. 3 15
      src/Composer/Util/RemoteFilesystem.php

+ 3 - 15
src/Composer/Util/RemoteFilesystem.php

@@ -125,18 +125,6 @@ class RemoteFilesystem
             if ($e instanceof TransportException && !empty($http_response_header[0])) {
             if ($e instanceof TransportException && !empty($http_response_header[0])) {
                 $e->setHeaders($http_response_header);
                 $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')) {
         if ($errorMessage && !ini_get('allow_url_fopen')) {
             $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
             $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
@@ -223,9 +211,6 @@ class RemoteFilesystem
     {
     {
         switch ($notificationCode) {
         switch ($notificationCode) {
             case STREAM_NOTIFY_FAILURE:
             case STREAM_NOTIFY_FAILURE:
-                throw new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.trim($message).')', $messageCode);
-                break;
-
             case STREAM_NOTIFY_AUTH_REQUIRED:
             case STREAM_NOTIFY_AUTH_REQUIRED:
                 if (401 === $messageCode) {
                 if (401 === $messageCode) {
                     if (!$this->io->isInteractive()) {
                     if (!$this->io->isInteractive()) {
@@ -240,7 +225,10 @@ class RemoteFilesystem
                     $this->io->setAuthentication($this->originUrl, $username, $password);
                     $this->io->setAuthentication($this->originUrl, $username, $password);
 
 
                     $this->get($this->originUrl, $this->fileUrl, $this->fileName, $this->progress);
                     $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;
                 break;
 
 
             case STREAM_NOTIFY_AUTH_RESULT:
             case STREAM_NOTIFY_AUTH_RESULT: