scratch – Blame information for rev 87

Subversion Repositories:
Rev:
Rev Author Line No. Line
87 office 1 <?php
2  
3 namespace GuzzleHttp;
4  
5 use GuzzleHttp\Event\HasEmitterInterface;
6 use GuzzleHttp\Exception\AdapterException;
7 use GuzzleHttp\Exception\RequestException;
8 use GuzzleHttp\Message\RequestInterface;
9 use GuzzleHttp\Message\ResponseInterface;
10  
11 /**
12 * Client interface for sending HTTP requests
13 */
14 interface ClientInterface extends HasEmitterInterface
15 {
16 const VERSION = '4.2.4';
17  
18 /**
19 * Create and return a new {@see RequestInterface} object.
20 *
21 * Use an absolute path to override the base path of the client, or a
22 * relative path to append to the base path of the client. The URL can
23 * contain the query string as well. Use an array to provide a URL
24 * template and additional variables to use in the URL template expansion.
25 *
26 * @param string $method HTTP method
27 * @param string|array|Url $url URL or URI template
28 * @param array $options Array of request options to apply.
29 *
30 * @return RequestInterface
31 */
32 public function createRequest($method, $url = null, array $options = []);
33  
34 /**
35 * Send a GET request
36 *
37 * @param string|array|Url $url URL or URI template
38 * @param array $options Array of request options to apply.
39 *
40 * @return ResponseInterface
41 * @throws RequestException When an error is encountered
42 */
43 public function get($url = null, $options = []);
44  
45 /**
46 * Send a HEAD request
47 *
48 * @param string|array|Url $url URL or URI template
49 * @param array $options Array of request options to apply.
50 *
51 * @return ResponseInterface
52 * @throws RequestException When an error is encountered
53 */
54 public function head($url = null, array $options = []);
55  
56 /**
57 * Send a DELETE request
58 *
59 * @param string|array|Url $url URL or URI template
60 * @param array $options Array of request options to apply.
61 *
62 * @return ResponseInterface
63 * @throws RequestException When an error is encountered
64 */
65 public function delete($url = null, array $options = []);
66  
67 /**
68 * Send a PUT request
69 *
70 * @param string|array|Url $url URL or URI template
71 * @param array $options Array of request options to apply.
72 *
73 * @return ResponseInterface
74 * @throws RequestException When an error is encountered
75 */
76 public function put($url = null, array $options = []);
77  
78 /**
79 * Send a PATCH request
80 *
81 * @param string|array|Url $url URL or URI template
82 * @param array $options Array of request options to apply.
83 *
84 * @return ResponseInterface
85 * @throws RequestException When an error is encountered
86 */
87 public function patch($url = null, array $options = []);
88  
89 /**
90 * Send a POST request
91 *
92 * @param string|array|Url $url URL or URI template
93 * @param array $options Array of request options to apply.
94 *
95 * @return ResponseInterface
96 * @throws RequestException When an error is encountered
97 */
98 public function post($url = null, array $options = []);
99  
100 /**
101 * Send an OPTIONS request
102 *
103 * @param string|array|Url $url URL or URI template
104 * @param array $options Array of request options to apply.
105 *
106 * @return ResponseInterface
107 * @throws RequestException When an error is encountered
108 */
109 public function options($url = null, array $options = []);
110  
111 /**
112 * Sends a single request
113 *
114 * @param RequestInterface $request Request to send
115 *
116 * @return \GuzzleHttp\Message\ResponseInterface
117 * @throws \LogicException When the adapter does not populate a response
118 * @throws RequestException When an error is encountered
119 */
120 public function send(RequestInterface $request);
121  
122 /**
123 * Sends multiple requests in parallel.
124 *
125 * Exceptions are not thrown for failed requests. Callers are expected to
126 * register an "error" option to handle request errors OR directly register
127 * an event handler for the "error" event of a request's
128 * event emitter.
129 *
130 * The option values for 'before', 'after', and 'error' can be a callable,
131 * an associative array containing event data, or an array of event data
132 * arrays. Event data arrays contain the following keys:
133 *
134 * - fn: callable to invoke that receives the event
135 * - priority: Optional event priority (defaults to 0)
136 * - once: Set to true so that the event is removed after it is triggered
137 *
138 * @param array|\Iterator $requests Requests to send in parallel
139 * @param array $options Associative array of options
140 * - parallel: (int) Maximum number of requests to send in parallel
141 * - before: (callable|array) Receives a BeforeEvent
142 * - complete: (callable|array) Receives a CompleteEvent
143 * - error: (callable|array) Receives a ErrorEvent
144 *
145 * @throws AdapterException When an error occurs in the HTTP adapter.
146 */
147 public function sendAll($requests, array $options = []);
148  
149 /**
150 * Get default request options of the client.
151 *
152 * @param string|null $keyOrPath The Path to a particular default request
153 * option to retrieve or pass null to retrieve all default request
154 * options. The syntax uses "/" to denote a path through nested PHP
155 * arrays. For example, "headers/content-type".
156 *
157 * @return mixed
158 */
159 public function getDefaultOption($keyOrPath = null);
160  
161 /**
162 * Set a default request option on the client so that any request created
163 * by the client will use the provided default value unless overridden
164 * explicitly when creating a request.
165 *
166 * @param string|null $keyOrPath The Path to a particular configuration
167 * value to set. The syntax uses a path notation that allows you to
168 * specify nested configuration values (e.g., 'headers/content-type').
169 * @param mixed $value Default request option value to set
170 */
171 public function setDefaultOption($keyOrPath, $value);
172  
173 /**
174 * Get the base URL of the client.
175 *
176 * @return string Returns the base URL if present
177 */
178 public function getBaseUrl();
179 }