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

Breadcrumb

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

function HttpDownloader::startJob

2 calls to HttpDownloader::startJob()
HttpDownloader::addJob in vendor/composer/composer/src/Composer/Util/HttpDownloader.php
@phpstan-param Request $request
HttpDownloader::countActiveJobs in vendor/composer/composer/src/Composer/Util/HttpDownloader.php
@internal

File

vendor/composer/composer/src/Composer/Util/HttpDownloader.php, line 305

Class

HttpDownloader
@author Jordi Boggiano <j.boggiano@seld.be> @phpstan-type Request array{url: non-empty-string, options: mixed[], copyTo: string|null} @phpstan-type Job array{id: int, status: int, request: Request, sync: bool, origin: string, resolve?: callable,…

Namespace

Composer\Util

Code

private function startJob(int $id) : void {
    $job =& $this->jobs[$id];
    if ($job['status'] !== self::STATUS_QUEUED) {
        return;
    }
    // start job
    $job['status'] = self::STATUS_STARTED;
    $this->runningJobs++;
    assert(isset($job['resolve']));
    assert(isset($job['reject']));
    $resolve = $job['resolve'];
    $reject = $job['reject'];
    $url = $job['request']['url'];
    $options = $job['request']['options'];
    $origin = $job['origin'];
    if ($this->disabled) {
        if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
            $resolve(new Response([
                'url' => $url,
            ], 304, [], ''));
        }
        else {
            $e = new TransportException('Network disabled, request canceled: ' . Url::sanitize($url), 499);
            $e->setStatusCode(499);
            $reject($e);
        }
        return;
    }
    try {
        if ($job['request']['copyTo']) {
            $job['curl_id'] = $this->curl
                ->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
        }
        else {
            $job['curl_id'] = $this->curl
                ->download($resolve, $reject, $origin, $url, $options);
        }
    } catch (\Exception $exception) {
        $reject($exception);
    }
}

API Navigation

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