Skip to content

Commit

Permalink
ID#234: added convenience method to retrieve one single request header.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Achatz committed Oct 31, 2014
1 parent f4d82d3 commit 960030f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions core/http/RequestImpl.php
Expand Up @@ -402,6 +402,25 @@ public function getHeaders() {
return $headers;
}

/**
* Returns a HTTP header instance by a given name. In case the header has not been sent
* along with the request, <em>null</em> is returned instead.
*
* @param string $name The name of the header to return.
*
* @return HeaderImpl|null The desired header instance or null.
*/
public function getHeader($name) {
/* @var $header HeaderImpl */
foreach ($this->getHeaders() as $header) {
if ($header->getName() == $name) {
return $header;
}
}

return null;
}

public function getMethod() {
return $_SERVER['REQUEST_METHOD'];
}
Expand Down

0 comments on commit 960030f

Please sign in to comment.