Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 224 lines (204 sloc) 9.921 kB
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
1 <?php
2
3 namespace Guzzle\Http;
4
5 use Guzzle\Common\HasDispatcherInterface;
6 use Guzzle\Common\Collection;
8deb2e3 @mtdowling PHPCS and PHPStorm cleanup. Closes #104.
mtdowling authored
7 use Guzzle\Common\Exception\InvalidArgumentException;
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
8 use Guzzle\Http\Message\EntityEnclosingRequestInterface;
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
9 use Guzzle\Http\Message\RequestInterface;
10
11 /**
12 * Client interface for send HTTP requests
13 */
14 interface ClientInterface extends HasDispatcherInterface
15 {
fa27732 @mtdowling [Http] Removing unnecessary __toString from Guzzle\Http\Client
mtdowling authored
16 const CREATE_REQUEST = 'client.create_request';
17
8bd4113 @mtdowling Formatting, cleaning, and sanitizing docblocks
mtdowling authored
18 /** @var string RFC 1123 HTTP-Date */
cf61aa9 @mtdowling Refactoring setUserAgent and Removing Guzzle\Http\Utils
mtdowling authored
19 const HTTP_DATE = 'D, d M Y H:i:s \G\M\T';
20
21 /**
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
22 * Set the configuration object to use with the client
23 *
c643c99 @mtdowling Adding the ability to specify default request options for every clien…
mtdowling authored
24 * @param array|Collection $config Parameters that define how the client behaves
25 *
aeef563 @mtdowling Updating Batch request transfer to not use CurlMutli objects. Trimmin…
mtdowling authored
26 * @return self
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
27 */
8deb2e3 @mtdowling PHPCS and PHPStorm cleanup. Closes #104.
mtdowling authored
28 public function setConfig($config);
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
29
30 /**
c643c99 @mtdowling Adding the ability to specify default request options for every clien…
mtdowling authored
31 * Get a configuration setting or all of the configuration settings. The Collection result of this method can be
32 * modified to change the configuration settings of a client.
33 *
34 * A client should honor the following special values:
35 *
36 * - request.options: Associative array of default RequestFactory options to apply to each request
37 * - request.params: Associative array of request parameters (data values) to apply to each request
38 * - curl.options: Associative array of cURL configuration settings to apply to each request
39 * - ssl.certificate_authority: Path a CAINFO, CAPATH, true to use strict defaults, or false to disable verification
40 * - redirect.disable: Set to true to disable redirects
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
41 *
aeef563 @mtdowling Updating Batch request transfer to not use CurlMutli objects. Trimmin…
mtdowling authored
42 * @param bool|string $key Configuration value to retrieve. Set to FALSE to retrieve all values of the client.
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
43 * The object return can be modified, and modifications will affect the client's config.
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
44 * @return mixed|Collection
c643c99 @mtdowling Adding the ability to specify default request options for every clien…
mtdowling authored
45 * @see \Guzzle\Http\Message\RequestFactoryInterface::applyOptions for a full list of request.options options
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
46 */
8deb2e3 @mtdowling PHPCS and PHPStorm cleanup. Closes #104.
mtdowling authored
47 public function getConfig($key = false);
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
48
49 /**
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
50 * Create and return a new {@see RequestInterface} configured for the client.
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
51 *
cdc7947 @mtdowling Cleaning up docblocks
mtdowling authored
52 * Use an absolute path to override the base path of the client, or a relative path to append to the base path of
aeef563 @mtdowling Updating Batch request transfer to not use CurlMutli objects. Trimmin…
mtdowling authored
53 * the client. The URI can contain the query string as well. Use an array to provide a URI template and additional
cdc7947 @mtdowling Cleaning up docblocks
mtdowling authored
54 * variables to use in the URI template expansion.
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
55 *
aeef563 @mtdowling Updating Batch request transfer to not use CurlMutli objects. Trimmin…
mtdowling authored
56 * @param string $method HTTP method. Defaults to GET
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
57 * @param string|array $uri Resource URI.
58 * @param array|Collection $headers HTTP headers
59 * @param string|resource|array|EntityBodyInterface $body Entity body of request (POST/PUT) or response (GET)
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
60 * @param array $options Array of options to apply to the request
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
61 *
62 * @return RequestInterface
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
63 * @throws InvalidArgumentException if a URI array is passed that does not contain exactly two elements: the URI
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
64 * followed by template variables
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
65 */
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
66 public function createRequest(
67 $method = RequestInterface::GET,
68 $uri = null,
69 $headers = null,
70 $body = null,
71 array $options = array()
72 );
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
73
74 /**
75 * Create a GET request for the client
76 *
23d4bd1 @mtdowling Giving ClientInterface::get() a much better API
mtdowling authored
77 * @param string|array $uri Resource URI
78 * @param array|Collection $headers HTTP headers
79 * @param array $options Options to apply to the request. For BC compatibility, you can also pass a
80 * string to tell Guzzle to download the body of the response to a particular
81 * location. Use the 'body' option instead for forward compatibility.
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
82 * @return RequestInterface
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
83 * @see Guzzle\Http\ClientInterface::createRequest()
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
84 */
23d4bd1 @mtdowling Giving ClientInterface::get() a much better API
mtdowling authored
85 public function get($uri = null, $headers = null, $options = array());
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
86
87 /**
88 * Create a HEAD request for the client
89 *
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
90 * @param string|array $uri Resource URI
1be9186 @mtdowling Removing (optional) from docblocks
mtdowling authored
91 * @param array|Collection $headers HTTP headers
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
92 * @param array $options Options to apply to the request
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
93 *
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
94 * @return RequestInterface
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
95 * @see Guzzle\Http\ClientInterface::createRequest()
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
96 */
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
97 public function head($uri = null, $headers = null, array $options = array());
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
98
99 /**
100 * Create a DELETE request for the client
101 *
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
102 * @param string|array $uri Resource URI
103 * @param array|Collection $headers HTTP headers
04f748f @mtdowling [Http] DELETE requests can now send along an entity body.
mtdowling authored
104 * @param string|resource|EntityBodyInterface $body Body to send in the request
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
105 * @param array $options Options to apply to the request
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
106 *
04f748f @mtdowling [Http] DELETE requests can now send along an entity body.
mtdowling authored
107 * @return EntityEnclosingRequestInterface
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
108 * @see Guzzle\Http\ClientInterface::createRequest()
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
109 */
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
110 public function delete($uri = null, $headers = null, $body = null, array $options = array());
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
111
112 /**
113 * Create a PUT request for the client
114 *
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
115 * @param string|array $uri Resource URI
116 * @param array|Collection $headers HTTP headers
117 * @param string|resource|EntityBodyInterface $body Body to send in the request
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
118 * @param array $options Options to apply to the request
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
119 *
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
120 * @return EntityEnclosingRequestInterface
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
121 * @see Guzzle\Http\ClientInterface::createRequest()
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
122 */
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
123 public function put($uri = null, $headers = null, $body = null, array $options = array());
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
124
125 /**
4773662 @mtdowling [Http] Removing final keyword from client verb methods
mtdowling authored
126 * Create a PATCH request for the client
127 *
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
128 * @param string|array $uri Resource URI
129 * @param array|Collection $headers HTTP headers
130 * @param string|resource|EntityBodyInterface $body Body to send in the request
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
131 * @param array $options Options to apply to the request
4773662 @mtdowling [Http] Removing final keyword from client verb methods
mtdowling authored
132 *
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
133 * @return EntityEnclosingRequestInterface
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
134 * @see Guzzle\Http\ClientInterface::createRequest()
4773662 @mtdowling [Http] Removing final keyword from client verb methods
mtdowling authored
135 */
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
136 public function patch($uri = null, $headers = null, $body = null, array $options = array());
4773662 @mtdowling [Http] Removing final keyword from client verb methods
mtdowling authored
137
138 /**
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
139 * Create a POST request for the client
140 *
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
141 * @param string|array $uri Resource URI
142 * @param array|Collection $headers HTTP headers
143 * @param array|Collection|string|EntityBodyInterface $postBody POST body. Can be a string, EntityBody, or
144 * associative array of POST fields to send in the body of the
aeef563 @mtdowling Updating Batch request transfer to not use CurlMutli objects. Trimmin…
mtdowling authored
145 * request. Prefix a value in the array with the @ symbol to
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
146 * reference a file.
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
147 * @param array $options Options to apply to the request
148 *
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
149 * @return EntityEnclosingRequestInterface
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
150 * @see Guzzle\Http\ClientInterface::createRequest()
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
151 */
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
152 public function post($uri = null, $headers = null, $postBody = null, array $options = array());
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
153
154 /**
155 * Create an OPTIONS request for the client
156 *
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
157 * @param string|array $uri Resource URI
158 * @param array $options Options to apply to the request
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
159 *
cf173bd @mtdowling Adding an EntityBodyInterface and cleaning up existing interfaces.
mtdowling authored
160 * @return RequestInterface
d2a23bf @mtdowling CS updates. Updating FromConfigInterface
mtdowling authored
161 * @see Guzzle\Http\ClientInterface::createRequest()
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
162 */
0ecee01 @mtdowling Moving the option application to RequestFactoryInterface. Adding opti…
mtdowling authored
163 public function options($uri = null, array $options = array());
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
164
165 /**
166 * Sends a single request or an array of requests in parallel
167 *
b675e40 @mtdowling Fixing ClientInterface::send() docblock. Removing unused variable.
mtdowling authored
168 * @param array|RequestInterface $requests One or more RequestInterface objects to send
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
169 *
aeef563 @mtdowling Updating Batch request transfer to not use CurlMutli objects. Trimmin…
mtdowling authored
170 * @return \Guzzle\Http\Message\Response|array Returns a single Response or an array of Response objects
c142f41 @mtdowling Guzzle 2.0
mtdowling authored
171 */
8deb2e3 @mtdowling PHPCS and PHPStorm cleanup. Closes #104.
mtdowling authored
172 public function send($requests);
cc81dac @mtdowling Reorganizing ClientInterface and removing setDefaultHeaders() from Cl…
mtdowling authored
173
174 /**
175 * Get the client's base URL as either an expanded or raw URI template
176 *
177 * @param bool $expand Set to FALSE to get the raw base URL without URI template expansion
178 *
179 * @return string|null
180 */
181 public function getBaseUrl($expand = true);
182
183 /**
184 * Set the base URL of the client
185 *
186 * @param string $url The base service endpoint URL of the webservice
187 *
188 * @return self
189 */
190 public function setBaseUrl($url);
191
192 /**
193 * Set the User-Agent header to be used on all requests from the client
194 *
195 * @param string $userAgent User agent string
196 * @param bool $includeDefault Set to true to prepend the value to Guzzle's default user agent string
197 *
198 * @return self
199 */
200 public function setUserAgent($userAgent, $includeDefault = false);
201
202 /**
203 * Set SSL verification options.
204 *
205 * Setting $certificateAuthority to TRUE will result in the bundled cacert.pem being used to verify against the
206 * remote host.
207 *
208 * Alternate certificates to verify against can be specified with the $certificateAuthority option set to the full
209 * path to a certificate file, or the path to a directory containing certificates.
210 *
211 * Setting $certificateAuthority to FALSE will turn off peer verification, unset the bundled cacert.pem, and
212 * disable host verification. Please don't do this unless you really know what you're doing, and why you're doing
213 * it.
214 *
215 * @param string|bool $certificateAuthority bool, file path, or directory path
216 * @param bool $verifyPeer FALSE to stop from verifying the peer's certificate.
217 * @param int $verifyHost Set to 1 to check the existence of a common name in the SSL peer
218 * certificate. 2 to check the existence of a common name and also verify
219 * that it matches the hostname provided.
220 * @return self
221 */
222 public function setSslVerification($certificateAuthority = true, $verifyPeer = true, $verifyHost = 2);
77a1783 @mtdowling Breaking / Potentially breaking changes:
mtdowling authored
223 }
Something went wrong with that request. Please try again.