3
declare(strict_types=1);
6
* This file is part of CodeIgniter 4 framework.
8
* (c) CodeIgniter Foundation <admin@codeigniter.com>
10
* For the full copyright and license information, please view
11
* the LICENSE file that was distributed with this source code.
14
namespace CodeIgniter\HTTP;
16
use CodeIgniter\HTTP\Exceptions\HTTPException;
19
* Expected behavior of an HTTP message
21
interface MessageInterface
24
* Retrieves the HTTP protocol version as a string.
26
* The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
28
* @return string HTTP protocol version.
30
public function getProtocolVersion(): string;
33
* Sets the body of the current message.
39
public function setBody($data);
42
* Gets the body of the message.
46
* @TODO Incompatible return type with PSR-7
48
public function getBody();
51
* Appends data to the body of the current message.
57
public function appendBody($data);
60
* Populates the $headers array with any headers the server knows about.
62
public function populateHeaders(): void;
65
* Returns an array containing all Headers.
67
* @return array<string, Header|list<Header>> An array of the Header objects
69
public function headers(): array;
72
* Checks if a header exists by the given case-insensitive name.
74
* @param string $name Case-insensitive header field name.
76
* @return bool Returns true if any header names match the given header
77
* name using a case-insensitive string comparison. Returns false if
78
* no matching header name is found in the message.
80
public function hasHeader(string $name): bool;
83
* Returns a single Header object. If multiple headers with the same
84
* name exist, then will return an array of header objects.
88
* @return Header|list<Header>|null
90
public function header($name);
93
* Retrieves a comma-separated string of the values for a single header.
95
* This method returns all of the header values of the given
96
* case-insensitive header name as a string concatenated together using
99
* NOTE: Not all header values may be appropriately represented using
100
* comma concatenation. For such headers, use getHeader() instead
101
* and supply your own delimiter when concatenating.
103
public function getHeaderLine(string $name): string;
106
* Sets a header and it's value.
108
* @param array|string|null $value
112
public function setHeader(string $name, $value);
115
* Removes a header from the list of headers we track.
119
public function removeHeader(string $name);
122
* Adds an additional header value to any headers that accept
123
* multiple values (i.e. are an array or implement ArrayAccess)
127
public function appendHeader(string $name, ?string $value);
130
* Adds an additional header value to any headers that accept
131
* multiple values (i.e. are an array or implement ArrayAccess)
135
public function prependHeader(string $name, string $value);
138
* Sets the HTTP protocol version.
142
* @throws HTTPException For invalid protocols
144
public function setProtocolVersion(string $version);