You are here

protected function WebTestBase::drupalGetHeader in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\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.

50 calls to WebTestBase::drupalGetHeader()
AggregatorRenderingTest::testBlockLinks in core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
Adds a feed block to the page and checks its links.
AggregatorRenderingTest::testFeedPage in core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
Creates a feed and checks that feed's page.
AjaxFormPageCacheTest::testSimpleAJAXFormValue in core/modules/system/src/Tests/Ajax/AjaxFormPageCacheTest.php
Create a simple form, then submit the form via AJAX to change to it.
BasicAuthTest::testBasicAuth in core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php
Test http basic authentication.
BlockTest::testBlockCacheTags in core/modules/block/src/Tests/BlockTest.php
Test that cache tags are properly set and bubbled up to the page cache.

... See full list

File

core/modules/simpletest/src/WebTestBase.php, line 2610
Contains \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;
}