protected HtmlResponseAttachmentsProcessor::setHeaders(HtmlResponse $response, array $headers)
Sets headers on a response object.
\Drupal\Core\Render\HtmlResponse $response: The HTML response to update.
array $headers: The headers to set, as an array. The items in this array should be as follows:
protected function setHeaders(HtmlResponse $response, array $headers) { foreach ($headers as $values) { $name = $values[0]; $value = $values[1]; $replace = !empty($values[2]); // Drupal treats the HTTP response status code like a header, even though // it really is not. if (strtolower($name) === 'status') { $response->setStatusCode($value); } else { $response->headers->set($name, $value, $replace); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!HtmlResponseAttachmentsProcessor.php/function/HtmlResponseAttachmentsProcessor::setHeaders/8.1.x