protected function WebTestBase::drupalGetHeader

Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed from last to first until the header is found.

Parameters

$name: The name of the header to retrieve. Names are case-insensitive (see RFC 2616 section 4.2).

$all_requests: Boolean value specifying whether to check all requests if the header is not found in the last request. Defaults to FALSE.

Return value

The HTTP header value or FALSE if not found.

14 calls to WebTestBase::drupalGetHeader()
ErrorHandlerTest::testExceptionHandler in drupal/core/modules/system/lib/Drupal/system/Tests/System/ErrorHandlerTest.php
Test the exception handler.
ImageFieldDisplayTest::_testImageFieldFormatters in drupal/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
Test image formatters on node display.
ImageStylesPathAndUrlTest::_testImageStyleUrlAndPath in drupal/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php
Test image_style_url().
PageCacheTest::testConditionalRequests in drupal/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php
Tests support of requests with If-Modified-Since and If-None-Match headers.
PageCacheTest::testPageCache in drupal/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php
Tests cache headers.

... See full list

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php, line 1979
Definition of Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function drupalGetHeader($name, $all_requests = FALSE) {
  $name = strtolower($name);
  $header = FALSE;
  if ($all_requests) {
    foreach (array_reverse($this
      ->drupalGetHeaders(TRUE)) as $headers) {
      if (isset($headers[$name])) {
        $header = $headers[$name];
        break;
      }
    }
  }
  else {
    $headers = $this
      ->drupalGetHeaders();
    if (isset($headers[$name])) {
      $header = $headers[$name];
    }
  }
  return $header;
}