Skip to content

Commit

Permalink
Host header access is non-optional, via all accessors
Browse files Browse the repository at this point in the history
- Made Host header retrieval non-optional
- Added overrides for getHeaders() and getHeaderLines() to ensure they
  always return the Host header as well.
  • Loading branch information
weierophinney committed Mar 3, 2015
1 parent 43330d7 commit 7d932c5
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,31 @@
*/
interface RequestInterface extends MessageInterface
{
/**
* Extends MessageInterface::getHeaders() to provide request-specific
* behavior.
*
* Retrieves all message headers.
*
* This method acts exactly like MessageInterface::getHeaders(), with one
* behavioral change: if the Host header has not been previously set, the
* method MUST attempt to pull the host segment of the composed URI, if
* present.
*
* @see MessageInterface::getHeaders()
* @see UriInterface::getHost()
* @return array Returns an associative array of the message's headers. Each
* key MUST be a header name, and each value MUST be an array of strings.
*/
public function getHeaders();

/**
* Extends MessageInterface::getHeader() to provide request-specific
* behavior.
*
* This method acts exactly like MessageInterface::getHeader(), with
* one behavioral change: if the Host header is requested, but has
* not been previously set, the method SHOULD attempt to pull the host
* not been previously set, the method MUST attempt to pull the host
* segment of the composed URI, if present.
*
* @see MessageInterface::getHeader()
Expand All @@ -36,6 +54,24 @@ interface RequestInterface extends MessageInterface
*/
public function getHeader($name);

/**
* Extends MessageInterface::getHeaderLines() to provide request-specific
* behavior.
*
* Retrieves a header by the given case-insensitive name as an array of strings.
*
* This method acts exactly like MessageInterface::getHeaderLines(), with
* one behavioral change: if the Host header is requested, but has
* not been previously set, the method MUST attempt to pull the host
* segment of the composed URI, if present.
*
* @see MessageInterface::getHeaderLines()
* @see UriInterface::getHost()
* @param string $name Case-insensitive header field name.
* @return string[]
*/
public function getHeaderLines($name);

/**
* Retrieves the message's request target.
*
Expand Down

0 comments on commit 7d932c5

Please sign in to comment.