You are here

public function Response::getHeader in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/browser-kit/Response.php \Symfony\Component\BrowserKit\Response::getHeader()

Gets a response header.

Parameters

string $header The header name:

bool $first Whether to return the first value or all header values:

Return value

string|array The first header value if $first is true, an array of values otherwise

File

vendor/symfony/browser-kit/Response.php, line 114

Class

Response
Response object.

Namespace

Symfony\Component\BrowserKit

Code

public function getHeader($header, $first = true) {
  $normalizedHeader = str_replace('-', '_', strtolower($header));
  foreach ($this->headers as $key => $value) {
    if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
      if ($first) {
        return is_array($value) ? count($value) ? $value[0] : '' : $value;
      }
      return is_array($value) ? $value : array(
        $value,
      );
    }
  }
  return $first ? null : array();
}