1 backdrop_web_test_case.php protected BackdropWebTestCase::backdropGetHeader($name, $all_requests = FALSE)

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

string|FALSE: The HTTP header value or FALSE if not found.

File

core/modules/simpletest/backdrop_web_test_case.php, line 3108

Class

BackdropWebTestCase
Test case for typical Backdrop tests.

Code

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