Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | /** |
| 3 | * Pop PHP Framework (https://www.popphp.org/) |
| 4 | * |
| 5 | * @link https://github.com/popphp/popphp-framework |
| 6 | * @author Nick Sagona, III <dev@noladev.com> |
| 7 | * @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC. |
| 8 | * @license https://www.popphp.org/license New BSD License |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @namespace |
| 13 | */ |
| 14 | namespace Pop\Http; |
| 15 | |
| 16 | use Pop\Mime\Part\Header; |
| 17 | use Pop\Mime\Part\Body; |
| 18 | |
| 19 | /** |
| 20 | * HTTP request/response interface |
| 21 | * |
| 22 | * @category Pop |
| 23 | * @package Pop\Http |
| 24 | * @author Nick Sagona, III <dev@noladev.com> |
| 25 | * @copyright Copyright (c) 2009-2025 NOLA Interactive, LLC. |
| 26 | * @license https://www.popphp.org/license New BSD License |
| 27 | * @version 5.3.2 |
| 28 | */ |
| 29 | interface RequestResponseInterface |
| 30 | { |
| 31 | |
| 32 | /** |
| 33 | * Set all headers (clear out any existing headers) |
| 34 | * |
| 35 | * @param array $headers |
| 36 | * @return RequestResponseInterface |
| 37 | */ |
| 38 | public function setHeaders(array $headers): RequestResponseInterface; |
| 39 | |
| 40 | /** |
| 41 | * Set a header |
| 42 | * |
| 43 | * @param Header|string|int $header |
| 44 | * @param ?string $value |
| 45 | * @return RequestResponseInterface |
| 46 | */ |
| 47 | public function addHeader(Header|string|int $header, ?string $value = null): RequestResponseInterface; |
| 48 | |
| 49 | /** |
| 50 | * Add all headers |
| 51 | * |
| 52 | * @param array $headers |
| 53 | * @return RequestResponseInterface |
| 54 | */ |
| 55 | public function addHeaders(array $headers): RequestResponseInterface; |
| 56 | |
| 57 | /** |
| 58 | * Get a header |
| 59 | * |
| 60 | * @param string $name |
| 61 | * @return mixed |
| 62 | */ |
| 63 | public function getHeader(string $name): mixed; |
| 64 | |
| 65 | /** |
| 66 | * Get a header |
| 67 | * |
| 68 | * @param string $name |
| 69 | * @return mixed |
| 70 | */ |
| 71 | public function getHeaderAsString(string $name): mixed; |
| 72 | |
| 73 | /** |
| 74 | * Get header value |
| 75 | * |
| 76 | * @param string $name |
| 77 | * @param int $i |
| 78 | * @return mixed |
| 79 | */ |
| 80 | public function getHeaderValue(string $name, int $i = 0): mixed; |
| 81 | |
| 82 | /** |
| 83 | * Get header value as string |
| 84 | * |
| 85 | * @param string $name |
| 86 | * @param int $i |
| 87 | * @return string|null |
| 88 | */ |
| 89 | public function getHeaderValueAsString(string $name, int $i = 0): string|null; |
| 90 | |
| 91 | /** |
| 92 | * Get all headers |
| 93 | * |
| 94 | * @return array |
| 95 | */ |
| 96 | public function getHeaders(): array; |
| 97 | |
| 98 | /** |
| 99 | * Get all header values as associative array |
| 100 | * |
| 101 | * @return array |
| 102 | */ |
| 103 | public function getHeadersAsArray(): array; |
| 104 | |
| 105 | /** |
| 106 | * Get all header values formatted string |
| 107 | * |
| 108 | * @param ?string $status |
| 109 | * @param string $eol |
| 110 | * @return string |
| 111 | */ |
| 112 | public function getHeadersAsString(?string $status = null, string $eol = "\r\n"): string; |
| 113 | |
| 114 | /** |
| 115 | * Determine if there are headers |
| 116 | * |
| 117 | * @return bool |
| 118 | */ |
| 119 | public function hasHeaders(): bool; |
| 120 | |
| 121 | /** |
| 122 | * Has a header |
| 123 | * |
| 124 | * @param string $name |
| 125 | * @return bool |
| 126 | */ |
| 127 | public function hasHeader(string $name): bool; |
| 128 | |
| 129 | /** |
| 130 | * Remove a header |
| 131 | * |
| 132 | * @param string $name |
| 133 | * @return RequestResponseInterface |
| 134 | */ |
| 135 | public function removeHeader(string $name): RequestResponseInterface; |
| 136 | |
| 137 | /** |
| 138 | * Remove all headers |
| 139 | * |
| 140 | * @return RequestResponseInterface |
| 141 | */ |
| 142 | public function removeHeaders(): RequestResponseInterface; |
| 143 | |
| 144 | /** |
| 145 | * Set the body |
| 146 | * |
| 147 | * @param string|Body $body |
| 148 | * @return RequestResponseInterface |
| 149 | */ |
| 150 | public function setBody(string|Body $body): RequestResponseInterface; |
| 151 | |
| 152 | /** |
| 153 | * Get the body |
| 154 | * |
| 155 | * @return Body |
| 156 | */ |
| 157 | public function getBody(): Body; |
| 158 | |
| 159 | /** |
| 160 | * Get body content |
| 161 | * |
| 162 | * @return mixed |
| 163 | */ |
| 164 | public function getBodyContent(): mixed; |
| 165 | |
| 166 | /** |
| 167 | * Get body content length |
| 168 | * |
| 169 | * @param bool $mb |
| 170 | * @return int |
| 171 | */ |
| 172 | public function getBodyContentLength(bool $mb = false): int; |
| 173 | |
| 174 | /** |
| 175 | * Has a body |
| 176 | * |
| 177 | * @return bool |
| 178 | */ |
| 179 | public function hasBody(): bool; |
| 180 | |
| 181 | /** |
| 182 | * Has body content |
| 183 | * |
| 184 | * @return bool |
| 185 | */ |
| 186 | public function hasBodyContent(): bool; |
| 187 | |
| 188 | /** |
| 189 | * Decode the body content |
| 190 | * |
| 191 | * @param ?string $body |
| 192 | * @return Body |
| 193 | */ |
| 194 | public function decodeBodyContent(?string $body = null): Body; |
| 195 | |
| 196 | /** |
| 197 | * Remove the body |
| 198 | * |
| 199 | * @return RequestResponseInterface |
| 200 | */ |
| 201 | public function removeBody(): RequestResponseInterface; |
| 202 | |
| 203 | } |