2
namespace GuzzleHttp\Message;
4
use GuzzleHttp\Stream\StreamInterface;
7
* Request and response message interface
9
interface MessageInterface
12
* Get a string representation of the message
16
public function __toString();
19
* Get the HTTP protocol version of the message
23
public function getProtocolVersion();
26
* Sets the body of the message.
28
* The body MUST be a StreamInterface object. Setting the body to null MUST
29
* remove the existing body.
31
* @param StreamInterface|null $body Body.
33
public function setBody(StreamInterface $body = null);
36
* Get the body of the message
38
* @return StreamInterface|null
40
public function getBody();
43
* Gets all message headers.
45
* The keys represent the header name as it will be sent over the wire, and
46
* each value is an array of strings associated with the header.
48
* // Represent the headers as a string
49
* foreach ($message->getHeaders() as $name => $values) {
50
* echo $name . ": " . implode(", ", $values);
53
* @return array Returns an associative array of the message's headers.
55
public function getHeaders();
58
* Retrieve a header by the given case-insensitive name.
60
* @param string $header Case-insensitive header name.
64
public function getHeader($header);
67
* Retrieves a header by the given case-insensitive name as an array of strings.
69
* @param string $header Case-insensitive header name.
73
public function getHeaderAsArray($header);
76
* Checks if a header exists by the given case-insensitive name.
78
* @param string $header Case-insensitive header name.
80
* @return bool Returns true if any header names match the given header
81
* name using a case-insensitive string comparison. Returns false if
82
* no matching header name is found in the message.
84
public function hasHeader($header);
87
* Remove a specific header by case-insensitive name.
89
* @param string $header Case-insensitive header name.
91
public function removeHeader($header);
94
* Appends a header value to any existing values associated with the
97
* @param string $header Header name to add
98
* @param string $value Value of the header
100
public function addHeader($header, $value);
103
* Merges in an associative array of headers.
105
* Each array key MUST be a string representing the case-insensitive name
106
* of a header. Each value MUST be either a string or an array of strings.
107
* For each value, the value is appended to any existing header of the same
108
* name, or, if a header does not already exist by the given name, then the
111
* @param array $headers Associative array of headers to add to the message
113
public function addHeaders(array $headers);
116
* Sets a header, replacing any existing values of any headers with the
117
* same case-insensitive name.
119
* The header values MUST be a string or an array of strings.
121
* @param string $header Header name
122
* @param string|array $value Header value(s)
124
public function setHeader($header, $value);
127
* Sets headers, replacing any headers that have already been set on the
130
* The array keys MUST be a string. The array values must be either a
131
* string or an array of strings.
133
* @param array $headers Headers to set.
135
public function setHeaders(array $headers);