|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Psr\Http\Message; |
| 4 | + |
| 5 | +/** |
| 6 | + * Representation of an outgoing, client-side request. |
| 7 | + * |
| 8 | + * Per the HTTP specification, this interface includes both accessors for |
| 9 | + * and mutators for the following: |
| 10 | + * |
| 11 | + * - Protocol version |
| 12 | + * - HTTP method |
| 13 | + * - URL |
| 14 | + * - Headers |
| 15 | + * - Message body |
| 16 | + * |
| 17 | + * As the request CAN be built iteratively, the interface allows |
| 18 | + * mutability of all properties. |
| 19 | + */ |
| 20 | +interface RequestInterface extends MessageInterface |
| 21 | +{ |
| 22 | + /** |
| 23 | + * Retrieves the HTTP method of the request. |
| 24 | + * |
| 25 | + * @return string Returns the request method. |
| 26 | + */ |
| 27 | + public function getMethod(); |
| 28 | + |
| 29 | + /** |
| 30 | + * Sets the HTTP method to be performed on the resource identified by the |
| 31 | + * Request-URI. |
| 32 | + * |
| 33 | + * While HTTP method names are typically all uppercase characters, HTTP |
| 34 | + * method names are case-sensitive and thus implementations SHOULD NOT |
| 35 | + * modify the given string. |
| 36 | + * |
| 37 | + * @param string $method Case-insensitive method. |
| 38 | + * @return void |
| 39 | + * @throws \InvalidArgumentException for invalid HTTP methods. |
| 40 | + */ |
| 41 | + public function setMethod($method); |
| 42 | + |
| 43 | + /** |
| 44 | + * Retrieves the base request URL. |
| 45 | + * |
| 46 | + * The base URL consists of: |
| 47 | + * |
| 48 | + * - scheme |
| 49 | + * - authentication (if any) |
| 50 | + * - server name/host |
| 51 | + * - port (if non-standard) |
| 52 | + * |
| 53 | + * This method is provided for convenience, particularly when considering |
| 54 | + * server-side requests, where data such as the scheme and server name may |
| 55 | + * need to be computed from more than one environmental variable. |
| 56 | + * |
| 57 | + * @link http://tools.ietf.org/html/rfc3986#section-4.3 |
| 58 | + * @return string Returns the base URL as a string. The URL MUST include |
| 59 | + * the scheme and host; if the port is non-standard for the scheme, |
| 60 | + * the port MUST be included; authentication data MAY be provided. |
| 61 | + */ |
| 62 | + public function getBaseUrl(); |
| 63 | + |
| 64 | + /** |
| 65 | + * Sets the base request URL. |
| 66 | + * |
| 67 | + * The base URL MUST be a string, and MUST include the scheme and host. |
| 68 | + * |
| 69 | + * If the port is non-standard for the scheme, the port MUST be provided. |
| 70 | + * |
| 71 | + * Authentication data MAY be provided. |
| 72 | + * |
| 73 | + * If path, query string, or URL fragment are provided they SHOULD be |
| 74 | + * stripped; optionally, an error MAY be raised in such situations. |
| 75 | + * |
| 76 | + * @link http://tools.ietf.org/html/rfc3986#section-4.3 |
| 77 | + * @param string $url Base request URL. |
| 78 | + * @return void |
| 79 | + * @throws \InvalidArgumentException If the URL is invalid. |
| 80 | + */ |
| 81 | + public function setBaseUrl($url); |
| 82 | + |
| 83 | + /** |
| 84 | + * Retrieves the request URL. |
| 85 | + * |
| 86 | + * The request URL is the same value as REQUEST_URI: the path and query |
| 87 | + * string ONLY. |
| 88 | + * |
| 89 | + * @link http://tools.ietf.org/html/rfc7230#section-5.3 |
| 90 | + * @return string Returns the URL as a string. The URL MUST be an |
| 91 | + * origin-form (path + query string), per RFC 7230 section 5.3 |
| 92 | + */ |
| 93 | + public function getUrl(); |
| 94 | + |
| 95 | + /** |
| 96 | + * Sets the request URL. |
| 97 | + * |
| 98 | + * The URL MUST be a string. The URL SHOULD be an origin-form (path + query |
| 99 | + * string) per RFC 7230 section 5.3; if other URL parts are present, the |
| 100 | + * method MUST raise an exception OR remove those parts. |
| 101 | + * |
| 102 | + * @link http://tools.ietf.org/html/rfc7230#section-5.3 |
| 103 | + * @param string $url Request URL, with path and optionally query string. |
| 104 | + * @return void |
| 105 | + * @throws \InvalidArgumentException If the URL is invalid. |
| 106 | + */ |
| 107 | + public function setUrl($url); |
| 108 | +} |
0 commit comments