4
* (c) Copyright 2014 Rackspace US, Inc.
6
* Licensed under the Apache License, Version 2.0 (the "License"); you may
7
* not use this file except in compliance with the License. You may obtain
8
* a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
* License for the specific language governing permissions and limitations
19
namespace OpenStack\Common\Transport;
22
* HTTP messages consist of requests from a client to a server and responses
23
* from a server to a client.
25
* @link https://github.com/php-fig/fig-standards/blob/master/proposed/http-message.md#31-psrhttpmessageinterface
27
interface MessageInterface
30
* Gets the HTTP protocol version.
32
* @return string HTTP protocol version.
34
public function getProtocolVersion();
37
* Gets the body of the message.
39
* @return StreamInterface|null Returns the body, or null if not set.
41
public function getBody();
44
* Sets the body of the message.
46
* The body MUST be a StreamInterface object. Setting the body to null MUST
47
* remove the existing body.
49
* @param StreamInterface|null $body Body.
51
* @return self Returns the message.
53
* @throws \InvalidArgumentException When the body is not valid.
55
public function setBody(/* StreamInterface */ $body = null);
58
* Gets all message headers.
60
* The keys represent the header name as it will be sent over the wire, and
61
* each value is an array of strings associated with the header.
63
* // Represent the headers as a string
64
* foreach ($message->getHeaders() as $name => $values) {
65
* echo $name . ": " . implode(", ", $values);
68
* @return array Returns an associative array of the message's headers.
70
public function getHeaders();
73
* Checks if a header exists by the given case-insensitive name.
75
* @param string $header Case-insensitive header name.
77
* @return bool Returns true if any header names match the given header
78
* name using a case-insensitive string comparison. Returns false if
79
* no matching header name is found in the message.
81
public function hasHeader($header);
84
* Retrieve a header by the given case-insensitive name.
86
* By default, this method returns all of the header values of the given
87
* case-insensitive header name as a string concatenated together using
88
* a comma. Because some header should not be concatenated together using a
89
* comma, this method provides a Boolean argument that can be used to
90
* retrieve the associated header values as an array of strings.
92
* @param string $header Case-insensitive header name.
93
* @param bool $asArray Set to true to retrieve the header value as an
96
* @return array|string
98
public function getHeader($header, $asArray = false);
101
* Sets a header, replacing any existing values of any headers with the
102
* same case-insensitive name.
104
* The header values MUST be a string or an array of strings.
106
* @param string $header Header name
107
* @param string|array $value Header value(s)
109
* @return self Returns the message.
111
public function setHeader($header, $value);
114
* Sets headers, replacing any headers that have already been set on the
117
* The array keys MUST be a string. The array values must be either a
118
* string or an array of strings.
120
* @param array $headers Headers to set.
122
* @return self Returns the message.
124
public function setHeaders(array $headers);
127
* Appends a header value to any existing values associated with the
130
* @param string $header Header name to add
131
* @param string $value Value of the header
135
public function addHeader($header, $value);
138
* Merges in an associative array of headers.
140
* Each array key MUST be a string representing the case-insensitive name
141
* of a header. Each value MUST be either a string or an array of strings.
142
* For each value, the value is appended to any existing header of the same
143
* name, or, if a header does not already exist by the given name, then the
146
* @param array $headers Associative array of headers to add to the message
150
public function addHeaders(array $headers);
153
* Remove a specific header by case-insensitive name.
155
* @param string $header HTTP header to remove
159
public function removeHeader($header);
b'\\ No newline at end of file'