Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
<?php
2
 
3
namespace Guzzle\Http\Message;
4
 
5
use Guzzle\Common\Collection;
6
use Guzzle\Common\HasDispatcherInterface;
7
use Guzzle\Http\Exception\RequestException;
8
use Guzzle\Http\ClientInterface;
9
use Guzzle\Http\EntityBodyInterface;
10
use Guzzle\Http\Url;
11
use Guzzle\Http\QueryString;
12
 
13
/**
14
 * Generic HTTP request interface
15
 */
16
interface RequestInterface extends MessageInterface, HasDispatcherInterface
17
{
18
    const STATE_NEW = 'new';
19
    const STATE_COMPLETE = 'complete';
20
    const STATE_TRANSFER = 'transfer';
21
    const STATE_ERROR = 'error';
22
 
23
    const GET = 'GET';
24
    const PUT = 'PUT';
25
    const POST = 'POST';
26
    const DELETE = 'DELETE';
27
    const HEAD = 'HEAD';
28
    const CONNECT = 'CONNECT';
29
    const OPTIONS = 'OPTIONS';
30
    const TRACE = 'TRACE';
31
    const PATCH = 'PATCH';
32
 
33
    /**
34
     * @return string
35
     */
36
    public function __toString();
37
 
38
    /**
39
     * Send the request
40
     *
41
     * @return Response
42
     * @throws RequestException on a request error
43
     */
44
    public function send();
45
 
46
    /**
47
     * Set the client used to transport the request
48
     *
49
     * @param ClientInterface $client
50
     *
51
     * @return self
52
     */
53
    public function setClient(ClientInterface $client);
54
 
55
    /**
56
     * Get the client used to transport the request
57
     *
58
     * @return ClientInterface $client
59
     */
60
    public function getClient();
61
 
62
    /**
63
     * Set the URL of the request
64
     *
65
     * @param string $url|Url Full URL to set including query string
66
     *
67
     * @return self
68
     */
69
    public function setUrl($url);
70
 
71
    /**
72
     * Get the full URL of the request (e.g. 'http://www.guzzle-project.com/')
73
     *
74
     * @param bool $asObject Set to TRUE to retrieve the URL as a clone of the URL object owned by the request.
75
     *
76
     * @return string|Url
77
     */
78
    public function getUrl($asObject = false);
79
 
80
    /**
81
     * Get the resource part of the the request, including the path, query string, and fragment
82
     *
83
     * @return string
84
     */
85
    public function getResource();
86
 
87
    /**
88
     * Get the collection of key value pairs that will be used as the query string in the request
89
     *
90
     * @return QueryString
91
     */
92
    public function getQuery();
93
 
94
    /**
95
     * Get the HTTP method of the request
96
     *
97
     * @return string
98
     */
99
    public function getMethod();
100
 
101
    /**
102
     * Get the URI scheme of the request (http, https, ftp, etc)
103
     *
104
     * @return string
105
     */
106
    public function getScheme();
107
 
108
    /**
109
     * Set the URI scheme of the request (http, https, ftp, etc)
110
     *
111
     * @param string $scheme Scheme to set
112
     *
113
     * @return self
114
     */
115
    public function setScheme($scheme);
116
 
117
    /**
118
     * Get the host of the request
119
     *
120
     * @return string
121
     */
122
    public function getHost();
123
 
124
    /**
125
     * Set the host of the request. Including a port in the host will modify the port of the request.
126
     *
127
     * @param string $host Host to set (e.g. www.yahoo.com, www.yahoo.com:80)
128
     *
129
     * @return self
130
     */
131
    public function setHost($host);
132
 
133
    /**
134
     * Get the path of the request (e.g. '/', '/index.html')
135
     *
136
     * @return string
137
     */
138
    public function getPath();
139
 
140
    /**
141
     * Set the path of the request (e.g. '/', '/index.html')
142
     *
143
     * @param string|array $path Path to set or array of segments to implode
144
     *
145
     * @return self
146
     */
147
    public function setPath($path);
148
 
149
    /**
150
     * Get the port that the request will be sent on if it has been set
151
     *
152
     * @return int|null
153
     */
154
    public function getPort();
155
 
156
    /**
157
     * Set the port that the request will be sent on
158
     *
159
     * @param int $port Port number to set
160
     *
161
     * @return self
162
     */
163
    public function setPort($port);
164
 
165
    /**
166
     * Get the username to pass in the URL if set
167
     *
168
     * @return string|null
169
     */
170
    public function getUsername();
171
 
172
    /**
173
     * Get the password to pass in the URL if set
174
     *
175
     * @return string|null
176
     */
177
    public function getPassword();
178
 
179
    /**
180
     * Set HTTP authorization parameters
181
     *
182
     * @param string|bool $user     User name or false disable authentication
183
     * @param string      $password Password
184
     * @param string      $scheme   Authentication scheme ('Basic', 'Digest', or a CURLAUTH_* constant (deprecated))
185
     *
186
     * @return self
187
     * @link http://www.ietf.org/rfc/rfc2617.txt
188
     * @link http://php.net/manual/en/function.curl-setopt.php See the available options for CURLOPT_HTTPAUTH
189
     * @throws RequestException
190
     */
191
    public function setAuth($user, $password = '', $scheme = 'Basic');
192
 
193
    /**
194
     * Get the HTTP protocol version of the request
195
     *
196
     * @return string
197
     */
198
    public function getProtocolVersion();
199
 
200
    /**
201
     * Set the HTTP protocol version of the request (e.g. 1.1 or 1.0)
202
     *
203
     * @param string $protocol HTTP protocol version to use with the request
204
     *
205
     * @return self
206
     */
207
    public function setProtocolVersion($protocol);
208
 
209
    /**
210
     * Get the previously received {@see Response} or NULL if the request has not been sent
211
     *
212
     * @return Response|null
213
     */
214
    public function getResponse();
215
 
216
    /**
217
     * Manually set a response for the request.
218
     *
219
     * This method is useful for specifying a mock response for the request or setting the response using a cache.
220
     * Manually setting a response will bypass the actual sending of a request.
221
     *
222
     * @param Response $response Response object to set
223
     * @param bool     $queued   Set to TRUE to keep the request in a state of not having been sent, but queue the
224
     *                           response for send()
225
     *
226
     * @return self Returns a reference to the object.
227
     */
228
    public function setResponse(Response $response, $queued = false);
229
 
230
    /**
231
     * The start of a response has been received for a request and the request is still in progress
232
     *
233
     * @param Response $response Response that has been received so far
234
     *
235
     * @return self
236
     */
237
    public function startResponse(Response $response);
238
 
239
    /**
240
     * Set the EntityBody that will hold a successful response message's entity body.
241
     *
242
     * This method should be invoked when you need to send the response's entity body somewhere other than the normal
243
     * php://temp buffer. For example, you can send the entity body to a socket, file, or some other custom stream.
244
     *
245
     * @param EntityBodyInterface|string|resource $body Response body object. Pass a string to attempt to store the
246
     *                                                  response body in a local file.
247
     * @return Request
248
     */
249
    public function setResponseBody($body);
250
 
251
    /**
252
     * Get the EntityBody that will hold the resulting response message's entity body. This response body will only
253
     * be used for successful responses. Intermediate responses (e.g. redirects) will not use the targeted response
254
     * body.
255
     *
256
     * @return EntityBodyInterface
257
     */
258
    public function getResponseBody();
259
 
260
    /**
261
     * Get the state of the request. One of 'complete', 'transfer', 'new', 'error'
262
     *
263
     * @return string
264
     */
265
    public function getState();
266
 
267
    /**
268
     * Set the state of the request
269
     *
270
     * @param string $state   State of the request ('complete', 'transfer', 'new', 'error')
271
     * @param array  $context Contextual information about the state change
272
     *
273
     * @return string Returns the current state of the request (which may have changed due to events being fired)
274
     */
275
    public function setState($state, array $context = array());
276
 
277
    /**
278
     * Get the cURL options that will be applied when the cURL handle is created
279
     *
280
     * @return Collection
281
     */
282
    public function getCurlOptions();
283
 
284
    /**
285
     * Get an array of Cookies
286
     *
287
     * @return array
288
     */
289
    public function getCookies();
290
 
291
    /**
292
     * Get a cookie value by name
293
     *
294
     * @param string $name Cookie to retrieve
295
     *
296
     * @return null|string
297
     */
298
    public function getCookie($name);
299
 
300
    /**
301
     * Add a Cookie value by name to the Cookie header
302
     *
303
     * @param string $name  Name of the cookie to add
304
     * @param string $value Value to set
305
     *
306
     * @return self
307
     */
308
    public function addCookie($name, $value);
309
 
310
    /**
311
     * Remove a specific cookie value by name
312
     *
313
     * @param string $name Cookie to remove by name
314
     *
315
     * @return self
316
     */
317
    public function removeCookie($name);
318
}