Returns a header value by name.
@api
string $key The header name:
mixed $default The default value:
Boolean $first Whether to return the first value or all header values:
string|array The first header value if $first is true, an array of values otherwise
public function get($key, $default = null, $first = true) {
$key = strtr(strtolower($key), '_', '-');
if (!array_key_exists($key, $this->headers)) {
if (null === $default) {
return $first ? null : array();
}
return $first ? $default : array(
$default,
);
}
if ($first) {
return count($this->headers[$key]) ? $this->headers[$key][0] : $default;
}
return $this->headers[$key];
}