You are here

protected function WebTestBase::drupalHead in SimpleTest 8.3

Retrieves only the headers for a Drupal path or an absolute path.

Parameters

$path: Drupal path or URL to load into internal browser

$options: Options to be forwarded to the url generator.

$headers: An array containing additional HTTP request headers, each formatted as "name: value".

Return value

The retrieved headers, also available as $this->getRawContent()

File

src/WebTestBase.php, line 1501

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalHead($path, array $options = [], array $headers = []) {
  $options['absolute'] = TRUE;
  $url = $this
    ->buildUrl($path, $options);
  $out = $this
    ->curlExec([
    CURLOPT_NOBODY => TRUE,
    CURLOPT_URL => $url,
    CURLOPT_HTTPHEADER => $headers,
  ]);

  // Ensure that any changes to variables in the other thread are picked up.
  $this
    ->refreshVariables();
  if ($this->dumpHeaders) {
    $this
      ->verbose('GET request to: ' . $path . '<hr />Ending URL: ' . $this
      ->getUrl() . '<hr />Headers: <pre>' . Html::escape(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>');
  }
  return $out;
}