function UpdateFetcher::doRequest

Same name in other branches
  1. 10 core/modules/update/src/UpdateFetcher.php \Drupal\update\UpdateFetcher::doRequest()
  2. 11.x core/modules/update/src/UpdateFetcher.php \Drupal\update\UpdateFetcher::doRequest()

Applies a GET request with a possible HTTP fallback.

This method falls back to HTTP in case there was some certificate problem.

Parameters

string $url: The URL.

array $options: The guzzle client options.

bool $with_http_fallback: Should the function fall back to HTTP.

Return value

string The body of the HTTP(S) request, or an empty string on failure.

1 call to UpdateFetcher::doRequest()
UpdateFetcher::fetchProjectData in core/modules/update/src/UpdateFetcher.php
Retrieves the project information.

File

core/modules/update/src/UpdateFetcher.php, line 96

Class

UpdateFetcher
Fetches project information from remote locations.

Namespace

Drupal\update

Code

protected function doRequest(string $url, array $options, bool $with_http_fallback) : string {
    $data = '';
    try {
        $data = (string) $this->httpClient
            ->get($url, [
            'headers' => [
                'Accept' => 'text/xml',
            ],
        ])
            ->getBody();
    } catch (TransferException $exception) {
        watchdog_exception('update', $exception);
        if ($with_http_fallback && strpos($url, "http://") === FALSE) {
            $url = str_replace('https://', 'http://', $url);
            return $this->doRequest($url, $options, FALSE);
        }
    }
    return $data;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.