upgrade zend (#1559)
[openemr.git] / vendor / psr / http-message / src / MessageInterface.php
blobdd46e5ec81eef701ccb6e61c08debe86570dcb8e
1 <?php
3 namespace Psr\Http\Message;
5 /**
6 * HTTP messages consist of requests from a client to a server and responses
7 * from a server to a client. This interface defines the methods common to
8 * each.
10 * Messages are considered immutable; all methods that might change state MUST
11 * be implemented such that they retain the internal state of the current
12 * message and return an instance that contains the changed state.
14 * @link http://www.ietf.org/rfc/rfc7230.txt
15 * @link http://www.ietf.org/rfc/rfc7231.txt
17 interface MessageInterface
19 /**
20 * Retrieves the HTTP protocol version as a string.
22 * The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").
24 * @return string HTTP protocol version.
26 public function getProtocolVersion();
28 /**
29 * Return an instance with the specified HTTP protocol version.
31 * The version string MUST contain only the HTTP version number (e.g.,
32 * "1.1", "1.0").
34 * This method MUST be implemented in such a way as to retain the
35 * immutability of the message, and MUST return an instance that has the
36 * new protocol version.
38 * @param string $version HTTP protocol version
39 * @return static
41 public function withProtocolVersion($version);
43 /**
44 * Retrieves all message header values.
46 * The keys represent the header name as it will be sent over the wire, and
47 * each value is an array of strings associated with the header.
49 * // Represent the headers as a string
50 * foreach ($message->getHeaders() as $name => $values) {
51 * echo $name . ": " . implode(", ", $values);
52 * }
54 * // Emit headers iteratively:
55 * foreach ($message->getHeaders() as $name => $values) {
56 * foreach ($values as $value) {
57 * header(sprintf('%s: %s', $name, $value), false);
58 * }
59 * }
61 * While header names are not case-sensitive, getHeaders() will preserve the
62 * exact case in which headers were originally specified.
64 * @return string[][] Returns an associative array of the message's headers. Each
65 * key MUST be a header name, and each value MUST be an array of strings
66 * for that header.
68 public function getHeaders();
70 /**
71 * Checks if a header exists by the given case-insensitive name.
73 * @param string $name Case-insensitive header field name.
74 * @return bool Returns true if any header names match the given header
75 * name using a case-insensitive string comparison. Returns false if
76 * no matching header name is found in the message.
78 public function hasHeader($name);
80 /**
81 * Retrieves a message header value by the given case-insensitive name.
83 * This method returns an array of all the header values of the given
84 * case-insensitive header name.
86 * If the header does not appear in the message, this method MUST return an
87 * empty array.
89 * @param string $name Case-insensitive header field name.
90 * @return string[] An array of string values as provided for the given
91 * header. If the header does not appear in the message, this method MUST
92 * return an empty array.
94 public function getHeader($name);
96 /**
97 * Retrieves a comma-separated string of the values for a single header.
99 * This method returns all of the header values of the given
100 * case-insensitive header name as a string concatenated together using
101 * a comma.
103 * NOTE: Not all header values may be appropriately represented using
104 * comma concatenation. For such headers, use getHeader() instead
105 * and supply your own delimiter when concatenating.
107 * If the header does not appear in the message, this method MUST return
108 * an empty string.
110 * @param string $name Case-insensitive header field name.
111 * @return string A string of values as provided for the given header
112 * concatenated together using a comma. If the header does not appear in
113 * the message, this method MUST return an empty string.
115 public function getHeaderLine($name);
118 * Return an instance with the provided value replacing the specified header.
120 * While header names are case-insensitive, the casing of the header will
121 * be preserved by this function, and returned from getHeaders().
123 * This method MUST be implemented in such a way as to retain the
124 * immutability of the message, and MUST return an instance that has the
125 * new and/or updated header and value.
127 * @param string $name Case-insensitive header field name.
128 * @param string|string[] $value Header value(s).
129 * @return static
130 * @throws \InvalidArgumentException for invalid header names or values.
132 public function withHeader($name, $value);
135 * Return an instance with the specified header appended with the given value.
137 * Existing values for the specified header will be maintained. The new
138 * value(s) will be appended to the existing list. If the header did not
139 * exist previously, it will be added.
141 * This method MUST be implemented in such a way as to retain the
142 * immutability of the message, and MUST return an instance that has the
143 * new header and/or value.
145 * @param string $name Case-insensitive header field name to add.
146 * @param string|string[] $value Header value(s).
147 * @return static
148 * @throws \InvalidArgumentException for invalid header names or values.
150 public function withAddedHeader($name, $value);
153 * Return an instance without the specified header.
155 * Header resolution MUST be done without case-sensitivity.
157 * This method MUST be implemented in such a way as to retain the
158 * immutability of the message, and MUST return an instance that removes
159 * the named header.
161 * @param string $name Case-insensitive header field name to remove.
162 * @return static
164 public function withoutHeader($name);
167 * Gets the body of the message.
169 * @return StreamInterface Returns the body as a stream.
171 public function getBody();
174 * Return an instance with the specified message body.
176 * The body MUST be a StreamInterface object.
178 * This method MUST be implemented in such a way as to retain the
179 * immutability of the message, and MUST return a new instance that has the
180 * new body stream.
182 * @param StreamInterface $body Body.
183 * @return static
184 * @throws \InvalidArgumentException When the body is not valid.
186 public function withBody(StreamInterface $body);