File indexing completed on 2025-01-26 05:29:15
0001 <?php 0002 0003 namespace Psr\Http\Message; 0004 0005 /** 0006 * Representation of an outgoing, client-side request. 0007 * 0008 * Per the HTTP specification, this interface includes properties for 0009 * each of the following: 0010 * 0011 * - Protocol version 0012 * - HTTP method 0013 * - URI 0014 * - Headers 0015 * - Message body 0016 * 0017 * During construction, implementations MUST attempt to set the Host header from 0018 * a provided URI if no Host header is provided. 0019 * 0020 * Requests are considered immutable; all methods that might change state MUST 0021 * be implemented such that they retain the internal state of the current 0022 * message and return an instance that contains the changed state. 0023 */ 0024 interface RequestInterface extends MessageInterface 0025 { 0026 /** 0027 * Retrieves the message's request target. 0028 * 0029 * Retrieves the message's request-target either as it will appear (for 0030 * clients), as it appeared at request (for servers), or as it was 0031 * specified for the instance (see withRequestTarget()). 0032 * 0033 * In most cases, this will be the origin-form of the composed URI, 0034 * unless a value was provided to the concrete implementation (see 0035 * withRequestTarget() below). 0036 * 0037 * If no URI is available, and no request-target has been specifically 0038 * provided, this method MUST return the string "/". 0039 * 0040 * @return string 0041 */ 0042 public function getRequestTarget(); 0043 0044 /** 0045 * Return an instance with the specific request-target. 0046 * 0047 * If the request needs a non-origin-form request-target — e.g., for 0048 * specifying an absolute-form, authority-form, or asterisk-form — 0049 * this method may be used to create an instance with the specified 0050 * request-target, verbatim. 0051 * 0052 * This method MUST be implemented in such a way as to retain the 0053 * immutability of the message, and MUST return an instance that has the 0054 * changed request target. 0055 * 0056 * @link http://tools.ietf.org/html/rfc7230#section-5.3 (for the various 0057 * request-target forms allowed in request messages) 0058 * @param mixed $requestTarget 0059 * @return static 0060 */ 0061 public function withRequestTarget($requestTarget); 0062 0063 /** 0064 * Retrieves the HTTP method of the request. 0065 * 0066 * @return string Returns the request method. 0067 */ 0068 public function getMethod(); 0069 0070 /** 0071 * Return an instance with the provided HTTP method. 0072 * 0073 * While HTTP method names are typically all uppercase characters, HTTP 0074 * method names are case-sensitive and thus implementations SHOULD NOT 0075 * modify the given string. 0076 * 0077 * This method MUST be implemented in such a way as to retain the 0078 * immutability of the message, and MUST return an instance that has the 0079 * changed request method. 0080 * 0081 * @param string $method Case-sensitive method. 0082 * @return static 0083 * @throws \InvalidArgumentException for invalid HTTP methods. 0084 */ 0085 public function withMethod($method); 0086 0087 /** 0088 * Retrieves the URI instance. 0089 * 0090 * This method MUST return a UriInterface instance. 0091 * 0092 * @link http://tools.ietf.org/html/rfc3986#section-4.3 0093 * @return UriInterface Returns a UriInterface instance 0094 * representing the URI of the request. 0095 */ 0096 public function getUri(); 0097 0098 /** 0099 * Returns an instance with the provided URI. 0100 * 0101 * This method MUST update the Host header of the returned request by 0102 * default if the URI contains a host component. If the URI does not 0103 * contain a host component, any pre-existing Host header MUST be carried 0104 * over to the returned request. 0105 * 0106 * You can opt-in to preserving the original state of the Host header by 0107 * setting `$preserveHost` to `true`. When `$preserveHost` is set to 0108 * `true`, this method interacts with the Host header in the following ways: 0109 * 0110 * - If the Host header is missing or empty, and the new URI contains 0111 * a host component, this method MUST update the Host header in the returned 0112 * request. 0113 * - If the Host header is missing or empty, and the new URI does not contain a 0114 * host component, this method MUST NOT update the Host header in the returned 0115 * request. 0116 * - If a Host header is present and non-empty, this method MUST NOT update 0117 * the Host header in the returned request. 0118 * 0119 * This method MUST be implemented in such a way as to retain the 0120 * immutability of the message, and MUST return an instance that has the 0121 * new UriInterface instance. 0122 * 0123 * @link http://tools.ietf.org/html/rfc3986#section-4.3 0124 * @param UriInterface $uri New request URI to use. 0125 * @param bool $preserveHost Preserve the original state of the Host header. 0126 * @return static 0127 */ 0128 public function withUri(UriInterface $uri, $preserveHost = false); 0129 }