function UpdateFetcher::doRequest

Same name and namespace in other branches
  1. 9 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 100

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 (ClientExceptionInterface $exception) {
    Error::logException($this->logger, $exception);
    if ($with_http_fallback && !str_contains($url, "http://")) {
      $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.