1: <?php
2:
3: namespace Guzzle\Http\Message;
4:
5: use Guzzle\Common\Exception\InvalidArgumentException;
6: use Guzzle\Common\Collection;
7:
8: /**
9: * Request and response message interface
10: */
11: interface MessageInterface
12: {
13: /**
14: * Get application and plugin specific parameters set on the message.
15: *
16: * @return Collection
17: */
18: public function getParams();
19:
20: /**
21: * Add a header to an existing collection of headers.
22: *
23: * @param string $header Header name to add
24: * @param string $value Value of the header
25: *
26: * @return MessageInterface
27: */
28: public function addHeader($header, $value);
29:
30: /**
31: * Add and merge in an array of HTTP headers.
32: *
33: * @param array $headers Associative array of header data.
34: *
35: * @return MessageInterface
36: */
37: public function addHeaders(array $headers);
38:
39: /**
40: * Retrieve an HTTP header by name. Performs a case-insensitive search of all headers.
41: *
42: * @param string $header Header to retrieve.
43: * @param bool $string Set to true to get the header as a string
44: *
45: * @return string|Header|null Returns NULL if no matching header is found. Returns a string if $string is set to
46: * TRUE. Returns a Header object if a matching header is found.
47: */
48: public function getHeader($header, $string = false);
49:
50: /**
51: * Get a tokenized header as a Collection
52: *
53: * @param string $header Header to retrieve
54: * @param string $token Token separator
55: *
56: * @return Collection|null
57: */
58: public function getTokenizedHeader($header, $token = ';');
59:
60: /**
61: * Set a tokenized header on the request that implodes a Collection of data into a string separated by a token.
62: *
63: * @param string $header Header to set
64: * @param array|Collection $data Header data
65: * @param string $token Token delimiter
66: *
67: * @return MessageInterface
68: * @throws InvalidArgumentException if data is not an array or Collection
69: */
70: public function setTokenizedHeader($header, $data, $token = ';');
71:
72: /**
73: * Get all headers as a collection
74: *
75: * @param bool $asObjects Set to true to retrieve a collection of Header objects
76: *
77: * @return Collection Returns a {@see Collection} of all headers
78: */
79: public function getHeaders($asObjects = false);
80:
81: /**
82: * Get an array of message header lines
83: *
84: * @return array
85: */
86: public function getHeaderLines();
87:
88: /**
89: * Check if the specified header is present.
90: *
91: * @param string $header The header to check.
92: *
93: * @return bool Returns TRUE or FALSE if the header is present
94: */
95: public function hasHeader($header);
96:
97: /**
98: * Remove a specific HTTP header.
99: *
100: * @param string $header HTTP header to remove.
101: *
102: * @return MessageInterface
103: */
104: public function removeHeader($header);
105:
106: /**
107: * Set an HTTP header
108: *
109: * @param string $header Name of the header to set.
110: * @param mixed $value Value to set.
111: *
112: * @return MessageInterface
113: */
114: public function setHeader($header, $value);
115:
116: /**
117: * Overwrite all HTTP headers with the supplied array of headers
118: *
119: * @param array $headers Associative array of header data.
120: *
121: * @return MessageInterface
122: */
123: public function setHeaders(array $headers);
124:
125: /**
126: * Get the raw message headers as a string
127: *
128: * @return string
129: */
130: public function getRawHeaders();
131:
132: /**
133: * Get a Cache-Control directive from the message
134: *
135: * @param string $directive Directive to retrieve
136: *
137: * @return null|string
138: */
139: public function getCacheControlDirective($directive);
140:
141: /**
142: * Check if the message has a Cache-Control directive
143: *
144: * @param string $directive Directive to check
145: *
146: * @return bool
147: */
148: public function hasCacheControlDirective($directive);
149:
150: /**
151: * Add a Cache-Control directive on the message
152: *
153: * @param string $directive Directive to set
154: * @param bool|string $value Value to set
155: *
156: * @return MessageInterface
157: */
158: public function addCacheControlDirective($directive, $value = true);
159:
160: /**
161: * Remove a Cache-Control directive from the message
162: *
163: * @param string $directive Directive to remove
164: *
165: * @return MessageInterface
166: */
167: public function removeCacheControlDirective($directive);
168: }
169: