1414 * - Headers
1515 * - Message body
1616 *
17+ * During construction, implementations MUST attempt to set the Host header from
18+ * a provided URI if no Host header is provided.
19+ *
1720 * Requests are considered immutable; all methods that might change state MUST
1821 * be implemented such that they retain the internal state of the current
1922 * message and return an instance that contains the changed state.
2023 */
2124interface RequestInterface extends MessageInterface
2225{
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 component 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-
41- /**
42- * Extends MessageInterface::getHeader() to provide request-specific
43- * behavior.
44- *
45- * This method acts exactly like MessageInterface::getHeader(), with
46- * one behavioral change: if the Host header is requested, but has
47- * not been previously set, the method MUST attempt to pull the host
48- * component of the composed URI, if present.
49- *
50- * @see MessageInterface::getHeader()
51- * @see UriInterface::getHost()
52- * @param string $name Case-insensitive header field name.
53- * @return string[] An array of string values as provided for the given
54- * header. If the header does not appear in the message, this method MUST
55- * return an empty array.
56- */
57- public function getHeader ($ name );
58-
59- /**
60- * Extends MessageInterface::getHeaderLines() to provide request-specific
61- * behavior.
62- *
63- * This method returns all of the header values of the given
64- * case-insensitive header name as a string concatenated together using
65- * a comma.
66- *
67- * This method acts exactly like MessageInterface::getHeaderLines(), with
68- * one behavioral change: if the Host header is requested, but has
69- * not been previously set, the method MUST attempt to pull the host
70- * component of the composed URI, if present.
71- *
72- * @see MessageInterface::getHeaderLine()
73- * @see UriInterface::getHost()
74- * @param string $name Case-insensitive header field name.
75- * @return string|null A string of values as provided for the given header
76- * concatenated together using a comma. If the header does not appear in
77- * the message, this method MUST return a null value.
78- */
79- public function getHeaderLine ($ name );
80-
8126 /**
8227 * Retrieves the message's request target.
8328 *
@@ -133,7 +78,7 @@ public function getMethod();
13378 * immutability of the message, and MUST return an instance that has the
13479 * changed request method.
13580 *
136- * @param string $method Case-insensitive method.
81+ * @param string $method Case-sensitive method.
13782 * @return self
13883 * @throws \InvalidArgumentException for invalid HTTP methods.
13984 */
@@ -153,18 +98,23 @@ public function getUri();
15398 /**
15499 * Returns an instance with the provided URI.
155100 *
156- * This method will update the Host header of the returned request by
101+ * This method MUST update the Host header of the returned request by
157102 * default if the URI contains a host component. If the URI does not
158- * contain a host component, any pre-existing Host header will be carried
103+ * contain a host component, any pre-existing Host header MUST be carried
159104 * over to the returned request.
160105 *
161106 * You can opt-in to preserving the original state of the Host header by
162107 * setting `$preserveHost` to `true`. When `$preserveHost` is set to
163- * `true`, the returned request will not update the Host header of the
164- * returned message -- even if the message contains no Host header. This
165- * means that a call to `getHeader('Host')` on the original request MUST
166- * equal the return value of a call to `getHeader('Host')` on the returned
167- * request.
108+ * `true`, this method interacts with the Host header in the following ways:
109+ *
110+ * - If the the Host header is missing or empty, and the new URI contains
111+ * a host component, this method MUST update the Host header in the returned
112+ * request.
113+ * - If the Host header is missing or empty, and the new URI does not contain a
114+ * host component, this method MUST NOT update the Host header in the returned
115+ * request.
116+ * - If a Host header is present and non-empty, this method MUST NOT update
117+ * the Host header in the returned request.
168118 *
169119 * This method MUST be implemented in such a way as to retain the
170120 * immutability of the message, and MUST return an instance that has the
0 commit comments