|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of CodeIgniter 4 framework. |
| 5 | + * |
| 6 | + * (c) CodeIgniter Foundation <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view |
| 9 | + * the LICENSE file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace CodeIgniter\HTTP; |
| 13 | + |
| 14 | +use InvalidArgumentException; |
| 15 | + |
| 16 | +/** |
| 17 | + * Representation of an outgoing, client-side request. |
| 18 | + * |
| 19 | + * Corresponds to Psr7\RequestInterface. |
| 20 | + */ |
| 21 | +interface OutgoingRequestInterface extends MessageInterface |
| 22 | +{ |
| 23 | + /** |
| 24 | + * Get the request method. |
| 25 | + * An extension of PSR-7's getMethod to allow casing. |
| 26 | + * |
| 27 | + * @param bool $upper Whether to return in upper or lower case. |
| 28 | + * |
| 29 | + * @deprecated The $upper functionality will be removed and this will revert to its PSR-7 equivalent |
| 30 | + */ |
| 31 | + public function getMethod(bool $upper = false): string; |
| 32 | + |
| 33 | + /** |
| 34 | + * Return an instance with the provided HTTP method. |
| 35 | + * |
| 36 | + * While HTTP method names are typically all uppercase characters, HTTP |
| 37 | + * method names are case-sensitive and thus implementations SHOULD NOT |
| 38 | + * modify the given string. |
| 39 | + * |
| 40 | + * This method MUST be implemented in such a way as to retain the |
| 41 | + * immutability of the message, and MUST return an instance that has the |
| 42 | + * changed request method. |
| 43 | + * |
| 44 | + * @param string $method Case-sensitive method. |
| 45 | + * |
| 46 | + * @return static |
| 47 | + * |
| 48 | + * @throws InvalidArgumentException for invalid HTTP methods. |
| 49 | + */ |
| 50 | + public function withMethod($method); |
| 51 | + |
| 52 | + /** |
| 53 | + * Retrieves the URI instance. |
| 54 | + * |
| 55 | + * @see http://tools.ietf.org/html/rfc3986#section-4.3 |
| 56 | + * |
| 57 | + * @return URI |
| 58 | + */ |
| 59 | + public function getUri(); |
| 60 | + |
| 61 | + /** |
| 62 | + * Returns an instance with the provided URI. |
| 63 | + * |
| 64 | + * This method MUST update the Host header of the returned request by |
| 65 | + * default if the URI contains a host component. If the URI does not |
| 66 | + * contain a host component, any pre-existing Host header MUST be carried |
| 67 | + * over to the returned request. |
| 68 | + * |
| 69 | + * You can opt-in to preserving the original state of the Host header by |
| 70 | + * setting `$preserveHost` to `true`. When `$preserveHost` is set to |
| 71 | + * `true`, this method interacts with the Host header in the following ways: |
| 72 | + * |
| 73 | + * - If the Host header is missing or empty, and the new URI contains |
| 74 | + * a host component, this method MUST update the Host header in the returned |
| 75 | + * request. |
| 76 | + * - If the Host header is missing or empty, and the new URI does not contain a |
| 77 | + * host component, this method MUST NOT update the Host header in the returned |
| 78 | + * request. |
| 79 | + * - If a Host header is present and non-empty, this method MUST NOT update |
| 80 | + * the Host header in the returned request. |
| 81 | + * |
| 82 | + * This method MUST be implemented in such a way as to retain the |
| 83 | + * immutability of the message, and MUST return an instance that has the |
| 84 | + * new UriInterface instance. |
| 85 | + * |
| 86 | + * @see http://tools.ietf.org/html/rfc3986#section-4.3 |
| 87 | + * |
| 88 | + * @param URI $uri New request URI to use. |
| 89 | + * @param bool $preserveHost Preserve the original state of the Host header. |
| 90 | + * |
| 91 | + * @return static |
| 92 | + */ |
| 93 | + public function withUri(URI $uri, $preserveHost = false); |
| 94 | +} |
0 commit comments