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

Breadcrumb

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

function HttpDownloader::get

Download a file synchronously

Parameters

string $url URL to download:

mixed[] $options Stream context options e.g. https://www.php.net/manual/en/context.http.php: although not all options are supported when using the default curl downloader

Return value

Response

Throws

TransportException

File

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

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

public function get(string $url, array $options = []) {
    if ('' === $url) {
        throw new \InvalidArgumentException('$url must not be an empty string');
    }
    [
        $job,
        $promise,
    ] = $this->addJob([
        'url' => $url,
        'options' => $options,
        'copyTo' => null,
    ], true);
    $promise->then(null, function (\Throwable $e) {
        // suppress error as it is rethrown to the caller by getResponse() a few lines below
    });
    $this->wait($job['id']);
    $response = $this->getResponse($job['id']);
    return $response;
}

API Navigation

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