protected function RESTTestBase::drupalGetHeaders in Drupal 8
Gets the HTTP response headers of the requested page.
Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the page. Headers from all requests may be requested by passing TRUE to this function.
Parameters
$all_requests: Boolean value specifying whether to return headers from all requests instead of just the last request. Defaults to FALSE.
Return value
A name/value array if headers from only the last request are requested. If headers from all requests are requested, an array of name/value arrays, one for each request.
The pseudonym ":status" is used for the HTTP status line.
Values for duplicate headers are stored as a single comma-separated list.
Overrides WebTestBase::drupalGetHeaders
File
- core/
modules/ rest/ src/ Tests/ RESTTestBase.php, line 260
Class
- RESTTestBase
- Test helper class that provides a REST client method to send HTTP requests.
Namespace
Drupal\rest\TestsCode
protected function drupalGetHeaders($all_requests = FALSE) {
if (!isset($this->response)) {
return parent::drupalGetHeaders($all_requests);
}
$lowercased_keys = array_map('strtolower', array_keys($this->response
->getHeaders()));
return array_map(function (array $header) {
return implode(', ', $header);
}, array_combine($lowercased_keys, array_values($this->response
->getHeaders())));
}