|
@@ -41,7 +41,9 @@ abstract class VcsDriver
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Get the https or http protocol.
|
|
|
+ * Get the https or http protocol depending on SSL support.
|
|
|
+ *
|
|
|
+ * Call this only if you know that the server supports both.
|
|
|
*
|
|
|
* @return string The correct type of protocol
|
|
|
*/
|
|
@@ -70,7 +72,6 @@ abstract class VcsDriver
|
|
|
if ($this->io->hasAuthorization($this->url)) {
|
|
|
$authStr = base64_encode($auth['username'] . ':' . $auth['password']);
|
|
|
$params['http'] = array('header' => "Authorization: Basic $authStr\r\n");
|
|
|
-
|
|
|
} else if (null !== $this->io->getLastUsername()) {
|
|
|
$authStr = base64_encode($this->io->getLastUsername() . ':' . $this->io->getLastPassword());
|
|
|
$params['http'] = array('header' => "Authorization: Basic $authStr\r\n");
|
|
@@ -91,54 +92,52 @@ abstract class VcsDriver
|
|
|
return $content;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Get notification action.
|
|
|
- *
|
|
|
- * @param integer $notificationCode The notification code
|
|
|
- * @param integer $severity The severity level
|
|
|
- * @param string $message The message
|
|
|
- * @param integer $messageCode The message code
|
|
|
- * @param integer $bytesTransferred The loaded size
|
|
|
- * @param integer $bytesMax The total size
|
|
|
+ /**
|
|
|
+ * Get notification action.
|
|
|
+ *
|
|
|
+ * @param integer $notificationCode The notification code
|
|
|
+ * @param integer $severity The severity level
|
|
|
+ * @param string $message The message
|
|
|
+ * @param integer $messageCode The message code
|
|
|
+ * @param integer $bytesTransferred The loaded size
|
|
|
+ * @param integer $bytesMax The total size
|
|
|
*/
|
|
|
protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
|
|
|
{
|
|
|
- switch ($notificationCode) {
|
|
|
+ switch ($notificationCode) {
|
|
|
case STREAM_NOTIFY_AUTH_REQUIRED:
|
|
|
case STREAM_NOTIFY_FAILURE:
|
|
|
// for private repository returning 404 error when the authorization is incorrect
|
|
|
- $auth = $this->io->getAuthorization($this->url);
|
|
|
+ $auth = $this->io->getAuthorization($this->url);
|
|
|
$ps = $this->firstCall && 404 === $messageCode
|
|
|
&& null === $this->io->getLastUsername()
|
|
|
&& null === $auth['username'];
|
|
|
|
|
|
if (404 === $messageCode && !$this->firstCall) {
|
|
|
throw new \RuntimeException("The '" . $this->contentUrl . "' URL not found");
|
|
|
- }
|
|
|
-
|
|
|
- if ($this->firstCall) {
|
|
|
- $this->firstCall = false;
|
|
|
}
|
|
|
|
|
|
+ $this->firstCall = false;
|
|
|
+
|
|
|
// get authorization informations
|
|
|
- if (401 === $messageCode || $ps) {
|
|
|
- if (!$this->io->isInteractive()) {
|
|
|
- $mess = "The '" . $this->contentUrl . "' URL not found";
|
|
|
-
|
|
|
- if (401 === $code || $ps) {
|
|
|
- $mess = "The '" . $this->contentUrl . "' URL required the authorization.\nYou must be used the interactive console";
|
|
|
- }
|
|
|
-
|
|
|
- throw new \RuntimeException($mess);
|
|
|
+ if (401 === $messageCode || $ps) {
|
|
|
+ if (!$this->io->isInteractive()) {
|
|
|
+ $mess = "The '" . $this->contentUrl . "' URL not found";
|
|
|
+
|
|
|
+ if (401 === $code || $ps) {
|
|
|
+ $mess = "The '" . $this->contentUrl . "' URL required the authorization.\nYou must be used the interactive console";
|
|
|
+ }
|
|
|
+
|
|
|
+ throw new \RuntimeException($mess);
|
|
|
}
|
|
|
|
|
|
- $this->io->writeln("Authorization for <info>" . $this->contentUrl . "</info>:");
|
|
|
- $username = $this->io->ask(' Username: ');
|
|
|
- $password = $this->io->askAndHideAnswer(' Password: ');
|
|
|
+ $this->io->write("Authorization for <info>" . $this->contentUrl . "</info>:");
|
|
|
+ $username = $this->io->ask(' Username: ');
|
|
|
+ $password = $this->io->askAndHideAnswer(' Password: ');
|
|
|
$this->io->setAuthorization($this->url, $username, $password);
|
|
|
|
|
|
$this->content = $this->getContents($this->contentUrl);
|
|
|
- }
|
|
|
+ }
|
|
|
break;
|
|
|
|
|
|
default:
|