You are here

protected function WebTestBase::drupalHead in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::drupalHead()

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()

3 calls to WebTestBase::drupalHead()
DownloadTest::doPrivateFileTransferTest in core/modules/file/src/Tests/DownloadTest.php
Test the private file transfer system.
DownloadTest::testPublicFileTransfer in core/modules/file/src/Tests/DownloadTest.php
Test the public file transfer system.
PageCacheTest::testConditionalRequests in core/modules/page_cache/src/Tests/PageCacheTest.php
Tests support of requests with If-Modified-Since and If-None-Match headers.

File

core/modules/simpletest/src/WebTestBase.php, line 2245
Contains \Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalHead($path, array $options = array(), array $headers = array()) {
  $options['absolute'] = TRUE;
  $url = $this
    ->buildUrl($path, $options);
  $out = $this
    ->curlExec(array(
    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;
}