You are here

protected function DrupalWebTestCase::drupalGetHeader in Drupal 7

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.

32 calls to DrupalWebTestCase::drupalGetHeader()
AJAXFormPageCacheTestCase::testSimpleAJAXFormValue in modules/simpletest/tests/ajax.test
Create a simple form, then POST to system/ajax to change to it.
BlockInterestCohortTest::testDefaultBlocking in modules/simpletest/tests/common.test
Tests that FLoC is blocked by default.
BlockInterestCohortTest::testDisableBlocking in modules/simpletest/tests/common.test
Tests that FLoC blocking can be disabled.
BlockInterestCohortTest::testExistingInterestCohortPolicy in modules/simpletest/tests/common.test
Tests that an existing interest-cohort policy is not overwritten.
BlockInterestCohortTest::testExistingPolicyHeader in modules/simpletest/tests/common.test
Tests that an existing header is appended to correctly.

... See full list

File

modules/simpletest/drupal_web_test_case.php, line 3109

Class

DrupalWebTestCase
Test case for typical Drupal tests.

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;
}