Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CurlDownloader.php

function CurlDownloader::isAuthenticatedRetryNeeded

Parameters

Job $job:

Return value

array{retry: bool, storeAuth: 'prompt'|bool}

1 call to CurlDownloader::isAuthenticatedRetryNeeded()
CurlDownloader::tick in vendor/composer/composer/src/Composer/Util/Http/CurlDownloader.php

File

vendor/composer/composer/src/Composer/Util/Http/CurlDownloader.php, line 545

Class

CurlDownloader
@internal @author Jordi Boggiano <j.boggiano@seld.be> @author Nicolas Grekas <p@tchwork.com> @phpstan-type Attributes array{retryAuthFailure: bool, redirects: int<0, max>, retries: int<0, max>, storeAuth:…

Namespace

Composer\Util\Http

Code

private function isAuthenticatedRetryNeeded(array $job, Response $response) : array {
    if (in_array($response->getStatusCode(), [
        401,
        403,
    ]) && $job['attributes']['retryAuthFailure']) {
        $result = $this->authHelper
            ->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders(), $job['attributes']['retries']);
        if ($result['retry']) {
            return $result;
        }
    }
    $locationHeader = $response->getHeader('location');
    $needsAuthRetry = false;
    // check for bitbucket login page asking to authenticate
    if ($job['origin'] === 'bitbucket.org' && !$this->authHelper
        ->isPublicBitBucketDownload($job['url']) && substr($job['url'], -4) === '.zip' && (!$locationHeader || substr($locationHeader, -4) !== '.zip') && Preg::isMatch('{^text/html\\b}i', $response->getHeader('content-type'))) {
        $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
    }
    // check for gitlab 404 when downloading archives
    if ($response->getStatusCode() === 404 && in_array($job['origin'], $this->config
        ->get('gitlab-domains'), true) && false !== strpos($job['url'], 'archive.zip')) {
        $needsAuthRetry = 'GitLab requires authentication and it was not provided';
    }
    if ($needsAuthRetry) {
        if ($job['attributes']['retryAuthFailure']) {
            $result = $this->authHelper
                ->promptAuthIfNeeded($job['url'], $job['origin'], 401, null, [], $job['attributes']['retries']);
            if ($result['retry']) {
                return $result;
            }
        }
        throw $this->failResponse($job, $response, $needsAuthRetry);
    }
    return [
        'retry' => false,
        'storeAuth' => false,
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal