-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
MessageInterface.php
145 lines (130 loc) · 3.97 KB
/
MessageInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* @package Guzzle PHP <http://www.guzzlephp.org>
* @license See the LICENSE file that was distributed with this source code.
*/
namespace Guzzle\Http\Message;
use Guzzle\Common\Collection;
/**
* HTTP messages consist of request messages that request data from a server,
* and response messages that carry back data from the server to the client.
*
* @author Michael Dowling <michael@guzzlephp.org>
*/
interface MessageInterface
{
/**
* Get application and plugin specific parameters set on the message. The
* return object is a reference to the internal object.
*
* @return Collection
*/
function getParams();
/**
* Add and merge in an array of HTTP headers.
*
* @param array $headers Associative array of header data.
*
* @return MessageInterface
*/
function addHeaders(array $headers);
/**
* Retrieve an HTTP header by name
*
* @param string $header The case-insensitive header to retrieve. Can be a
* regular expression
* @param mixed $default (optional) If the header is not found, the passed
* $default value will be returned
*
* @return string|null Returns the matching HTTP header or NULL if the
* header is not found
*/
function getHeader($header, $default = null);
/**
* Get all or all matching headers.
*
* @param array $names (optional) Pass an array of header names to retrieve
* only a particular subset of headers. Regular expressions are
* accepted in the $names array of values.
*
* @return array Returns an array of all headers if no $names array is
* specified, or an array of only the headers matching the values in
* the $names array.
*/
function getHeaders(array $headers = null);
/**
* Returns TRUE or FALSE if the specified header is present.
*
* @param string $header The header to check. This parameter can also be a
* regular expression
* @param bool $caseInsensitive (optional) Set to TRUE to compliment the
* $header argument and match headers in a case-insensitive comparison.
*
* @return bool Returns TRUE if the header is present and FALSE if not set
*/
function hasHeader($header, $caseInsensitive = false);
/**
* Remove a specific HTTP header.
*
* @param string $header HTTP header to remove.
*
* @return MessageInterface
*/
function removeHeader($header);
/**
* Set an HTTP header
*
* @param string $header Name of the header to set.
* @param mixed $value Value to set.
*
* @return MessageInterface
*/
function setHeader($header, $value);
/**
* Overwrite all HTTP headers with the supplied array of headers
*
* @param array $headers Associative array of header data.
*
* @return MessageInterface
*/
function setHeaders(array $headers);
/**
* Get the raw message headers as a string
*
* @return string
*/
function getRawHeaders();
/**
* Get a Cache-Control directive from the message
*
* @param string $directive Directive to retrieve
*
* @return null|string
*/
function getCacheControlDirective($directive);
/**
* Check if the message has a Cache-Control directive
*
* @param string $directive Directive to check
*
* @return bool
*/
function hasCacheControlDirective($directive);
/**
* Add a Cache-Control directive on the message
*
* @param string $directive Directive to set
* @param bool|string $value Value to set
*
* @return MessageInterface
*/
function addCacheControlDirective($directive, $value);
/**
* Remove a Cache-Control directive from the message
*
* @param string $directive Directive to remove
*
* @return MessageInterface
*/
function removeCacheControlDirective($directive);
}