Response: Add method getHeader

refs #12161
This commit is contained in:
Noah Hilverling 2016-10-18 09:58:33 +02:00
parent c927c32442
commit f95c789353
1 changed files with 25 additions and 0 deletions

View File

@ -153,6 +153,31 @@ class Response extends Zend_Controller_Response_Http
return $this;
}
/**
* Get an array of every header value with a specified name
*
* @param string $name
* @param bool $lastOnly If this is true, the last value will be returned as a string.
*
* @return null|array|string
*/
public function getHeader($name, $lastOnly = false)
{
$result = ($lastOnly ? null : array());
$headers = $this->getHeaders();
foreach ($headers as $header) {
if ($header['name'] === $name) {
if ($lastOnly) {
$result = $header['value'];
} else {
$result[] = $header['value'];
}
}
}
return $result;
}
/**
* Get the request
*