Skip to content

Commit 7d932c5

Browse files
committed
Host header access is non-optional, via all accessors
- Made Host header retrieval non-optional - Added overrides for getHeaders() and getHeaderLines() to ensure they always return the Host header as well.
1 parent 43330d7 commit 7d932c5

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

src/RequestInterface.php

+37-1
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,31 @@
2020
*/
2121
interface RequestInterface extends MessageInterface
2222
{
23+
/**
24+
* Extends MessageInterface::getHeaders() to provide request-specific
25+
* behavior.
26+
*
27+
* Retrieves all message headers.
28+
*
29+
* This method acts exactly like MessageInterface::getHeaders(), with one
30+
* behavioral change: if the Host header has not been previously set, the
31+
* method MUST attempt to pull the host segment of the composed URI, if
32+
* present.
33+
*
34+
* @see MessageInterface::getHeaders()
35+
* @see UriInterface::getHost()
36+
* @return array Returns an associative array of the message's headers. Each
37+
* key MUST be a header name, and each value MUST be an array of strings.
38+
*/
39+
public function getHeaders();
40+
2341
/**
2442
* Extends MessageInterface::getHeader() to provide request-specific
2543
* behavior.
2644
*
2745
* This method acts exactly like MessageInterface::getHeader(), with
2846
* one behavioral change: if the Host header is requested, but has
29-
* not been previously set, the method SHOULD attempt to pull the host
47+
* not been previously set, the method MUST attempt to pull the host
3048
* segment of the composed URI, if present.
3149
*
3250
* @see MessageInterface::getHeader()
@@ -36,6 +54,24 @@ interface RequestInterface extends MessageInterface
3654
*/
3755
public function getHeader($name);
3856

57+
/**
58+
* Extends MessageInterface::getHeaderLines() to provide request-specific
59+
* behavior.
60+
*
61+
* Retrieves a header by the given case-insensitive name as an array of strings.
62+
*
63+
* This method acts exactly like MessageInterface::getHeaderLines(), with
64+
* one behavioral change: if the Host header is requested, but has
65+
* not been previously set, the method MUST attempt to pull the host
66+
* segment of the composed URI, if present.
67+
*
68+
* @see MessageInterface::getHeaderLines()
69+
* @see UriInterface::getHost()
70+
* @param string $name Case-insensitive header field name.
71+
* @return string[]
72+
*/
73+
public function getHeaderLines($name);
74+
3975
/**
4076
* Retrieves the message's request target.
4177
*

0 commit comments

Comments
 (0)