Chris@0
|
1 <?php
|
Chris@0
|
2 namespace GuzzleHttp;
|
Chris@0
|
3
|
Chris@0
|
4 /**
|
Chris@0
|
5 * This class contains a list of built-in Guzzle request options.
|
Chris@0
|
6 *
|
Chris@0
|
7 * More documentation for each option can be found at http://guzzlephp.org/.
|
Chris@0
|
8 *
|
Chris@0
|
9 * @link http://docs.guzzlephp.org/en/v6/request-options.html
|
Chris@0
|
10 */
|
Chris@0
|
11 final class RequestOptions
|
Chris@0
|
12 {
|
Chris@0
|
13 /**
|
Chris@0
|
14 * allow_redirects: (bool|array) Controls redirect behavior. Pass false
|
Chris@0
|
15 * to disable redirects, pass true to enable redirects, pass an
|
Chris@0
|
16 * associative to provide custom redirect settings. Defaults to "false".
|
Chris@0
|
17 * This option only works if your handler has the RedirectMiddleware. When
|
Chris@0
|
18 * passing an associative array, you can provide the following key value
|
Chris@0
|
19 * pairs:
|
Chris@0
|
20 *
|
Chris@0
|
21 * - max: (int, default=5) maximum number of allowed redirects.
|
Chris@0
|
22 * - strict: (bool, default=false) Set to true to use strict redirects
|
Chris@0
|
23 * meaning redirect POST requests with POST requests vs. doing what most
|
Chris@0
|
24 * browsers do which is redirect POST requests with GET requests
|
Chris@0
|
25 * - referer: (bool, default=true) Set to false to disable the Referer
|
Chris@0
|
26 * header.
|
Chris@0
|
27 * - protocols: (array, default=['http', 'https']) Allowed redirect
|
Chris@0
|
28 * protocols.
|
Chris@0
|
29 * - on_redirect: (callable) PHP callable that is invoked when a redirect
|
Chris@0
|
30 * is encountered. The callable is invoked with the request, the redirect
|
Chris@0
|
31 * response that was received, and the effective URI. Any return value
|
Chris@0
|
32 * from the on_redirect function is ignored.
|
Chris@0
|
33 */
|
Chris@0
|
34 const ALLOW_REDIRECTS = 'allow_redirects';
|
Chris@0
|
35
|
Chris@0
|
36 /**
|
Chris@0
|
37 * auth: (array) Pass an array of HTTP authentication parameters to use
|
Chris@0
|
38 * with the request. The array must contain the username in index [0],
|
Chris@0
|
39 * the password in index [1], and you can optionally provide a built-in
|
Chris@0
|
40 * authentication type in index [2]. Pass null to disable authentication
|
Chris@0
|
41 * for a request.
|
Chris@0
|
42 */
|
Chris@0
|
43 const AUTH = 'auth';
|
Chris@0
|
44
|
Chris@0
|
45 /**
|
Chris@0
|
46 * body: (resource|string|null|int|float|StreamInterface|callable|\Iterator)
|
Chris@0
|
47 * Body to send in the request.
|
Chris@0
|
48 */
|
Chris@0
|
49 const BODY = 'body';
|
Chris@0
|
50
|
Chris@0
|
51 /**
|
Chris@0
|
52 * cert: (string|array) Set to a string to specify the path to a file
|
Chris@0
|
53 * containing a PEM formatted SSL client side certificate. If a password
|
Chris@0
|
54 * is required, then set cert to an array containing the path to the PEM
|
Chris@0
|
55 * file in the first array element followed by the certificate password
|
Chris@0
|
56 * in the second array element.
|
Chris@0
|
57 */
|
Chris@0
|
58 const CERT = 'cert';
|
Chris@0
|
59
|
Chris@0
|
60 /**
|
Chris@0
|
61 * cookies: (bool|GuzzleHttp\Cookie\CookieJarInterface, default=false)
|
Chris@0
|
62 * Specifies whether or not cookies are used in a request or what cookie
|
Chris@0
|
63 * jar to use or what cookies to send. This option only works if your
|
Chris@0
|
64 * handler has the `cookie` middleware. Valid values are `false` and
|
Chris@0
|
65 * an instance of {@see GuzzleHttp\Cookie\CookieJarInterface}.
|
Chris@0
|
66 */
|
Chris@0
|
67 const COOKIES = 'cookies';
|
Chris@0
|
68
|
Chris@0
|
69 /**
|
Chris@0
|
70 * connect_timeout: (float, default=0) Float describing the number of
|
Chris@0
|
71 * seconds to wait while trying to connect to a server. Use 0 to wait
|
Chris@0
|
72 * indefinitely (the default behavior).
|
Chris@0
|
73 */
|
Chris@0
|
74 const CONNECT_TIMEOUT = 'connect_timeout';
|
Chris@0
|
75
|
Chris@0
|
76 /**
|
Chris@0
|
77 * debug: (bool|resource) Set to true or set to a PHP stream returned by
|
Chris@0
|
78 * fopen() enable debug output with the HTTP handler used to send a
|
Chris@0
|
79 * request.
|
Chris@0
|
80 */
|
Chris@0
|
81 const DEBUG = 'debug';
|
Chris@0
|
82
|
Chris@0
|
83 /**
|
Chris@0
|
84 * decode_content: (bool, default=true) Specify whether or not
|
Chris@0
|
85 * Content-Encoding responses (gzip, deflate, etc.) are automatically
|
Chris@0
|
86 * decoded.
|
Chris@0
|
87 */
|
Chris@0
|
88 const DECODE_CONTENT = 'decode_content';
|
Chris@0
|
89
|
Chris@0
|
90 /**
|
Chris@0
|
91 * delay: (int) The amount of time to delay before sending in milliseconds.
|
Chris@0
|
92 */
|
Chris@0
|
93 const DELAY = 'delay';
|
Chris@0
|
94
|
Chris@0
|
95 /**
|
Chris@0
|
96 * expect: (bool|integer) Controls the behavior of the
|
Chris@0
|
97 * "Expect: 100-Continue" header.
|
Chris@0
|
98 *
|
Chris@0
|
99 * Set to `true` to enable the "Expect: 100-Continue" header for all
|
Chris@0
|
100 * requests that sends a body. Set to `false` to disable the
|
Chris@0
|
101 * "Expect: 100-Continue" header for all requests. Set to a number so that
|
Chris@0
|
102 * the size of the payload must be greater than the number in order to send
|
Chris@0
|
103 * the Expect header. Setting to a number will send the Expect header for
|
Chris@0
|
104 * all requests in which the size of the payload cannot be determined or
|
Chris@0
|
105 * where the body is not rewindable.
|
Chris@0
|
106 *
|
Chris@0
|
107 * By default, Guzzle will add the "Expect: 100-Continue" header when the
|
Chris@0
|
108 * size of the body of a request is greater than 1 MB and a request is
|
Chris@0
|
109 * using HTTP/1.1.
|
Chris@0
|
110 */
|
Chris@0
|
111 const EXPECT = 'expect';
|
Chris@0
|
112
|
Chris@0
|
113 /**
|
Chris@0
|
114 * form_params: (array) Associative array of form field names to values
|
Chris@0
|
115 * where each value is a string or array of strings. Sets the Content-Type
|
Chris@0
|
116 * header to application/x-www-form-urlencoded when no Content-Type header
|
Chris@0
|
117 * is already present.
|
Chris@0
|
118 */
|
Chris@0
|
119 const FORM_PARAMS = 'form_params';
|
Chris@0
|
120
|
Chris@0
|
121 /**
|
Chris@0
|
122 * headers: (array) Associative array of HTTP headers. Each value MUST be
|
Chris@0
|
123 * a string or array of strings.
|
Chris@0
|
124 */
|
Chris@0
|
125 const HEADERS = 'headers';
|
Chris@0
|
126
|
Chris@0
|
127 /**
|
Chris@0
|
128 * http_errors: (bool, default=true) Set to false to disable exceptions
|
Chris@0
|
129 * when a non- successful HTTP response is received. By default,
|
Chris@0
|
130 * exceptions will be thrown for 4xx and 5xx responses. This option only
|
Chris@0
|
131 * works if your handler has the `httpErrors` middleware.
|
Chris@0
|
132 */
|
Chris@0
|
133 const HTTP_ERRORS = 'http_errors';
|
Chris@0
|
134
|
Chris@0
|
135 /**
|
Chris@0
|
136 * json: (mixed) Adds JSON data to a request. The provided value is JSON
|
Chris@0
|
137 * encoded and a Content-Type header of application/json will be added to
|
Chris@0
|
138 * the request if no Content-Type header is already present.
|
Chris@0
|
139 */
|
Chris@0
|
140 const JSON = 'json';
|
Chris@0
|
141
|
Chris@0
|
142 /**
|
Chris@0
|
143 * multipart: (array) Array of associative arrays, each containing a
|
Chris@0
|
144 * required "name" key mapping to the form field, name, a required
|
Chris@0
|
145 * "contents" key mapping to a StreamInterface|resource|string, an
|
Chris@0
|
146 * optional "headers" associative array of custom headers, and an
|
Chris@0
|
147 * optional "filename" key mapping to a string to send as the filename in
|
Chris@0
|
148 * the part. If no "filename" key is present, then no "filename" attribute
|
Chris@0
|
149 * will be added to the part.
|
Chris@0
|
150 */
|
Chris@0
|
151 const MULTIPART = 'multipart';
|
Chris@0
|
152
|
Chris@0
|
153 /**
|
Chris@0
|
154 * on_headers: (callable) A callable that is invoked when the HTTP headers
|
Chris@0
|
155 * of the response have been received but the body has not yet begun to
|
Chris@0
|
156 * download.
|
Chris@0
|
157 */
|
Chris@0
|
158 const ON_HEADERS = 'on_headers';
|
Chris@0
|
159
|
Chris@0
|
160 /**
|
Chris@0
|
161 * on_stats: (callable) allows you to get access to transfer statistics of
|
Chris@0
|
162 * a request and access the lower level transfer details of the handler
|
Chris@0
|
163 * associated with your client. ``on_stats`` is a callable that is invoked
|
Chris@0
|
164 * when a handler has finished sending a request. The callback is invoked
|
Chris@0
|
165 * with transfer statistics about the request, the response received, or
|
Chris@0
|
166 * the error encountered. Included in the data is the total amount of time
|
Chris@0
|
167 * taken to send the request.
|
Chris@0
|
168 */
|
Chris@0
|
169 const ON_STATS = 'on_stats';
|
Chris@0
|
170
|
Chris@0
|
171 /**
|
Chris@0
|
172 * progress: (callable) Defines a function to invoke when transfer
|
Chris@0
|
173 * progress is made. The function accepts the following positional
|
Chris@0
|
174 * arguments: the total number of bytes expected to be downloaded, the
|
Chris@0
|
175 * number of bytes downloaded so far, the number of bytes expected to be
|
Chris@0
|
176 * uploaded, the number of bytes uploaded so far.
|
Chris@0
|
177 */
|
Chris@0
|
178 const PROGRESS = 'progress';
|
Chris@0
|
179
|
Chris@0
|
180 /**
|
Chris@0
|
181 * proxy: (string|array) Pass a string to specify an HTTP proxy, or an
|
Chris@0
|
182 * array to specify different proxies for different protocols (where the
|
Chris@0
|
183 * key is the protocol and the value is a proxy string).
|
Chris@0
|
184 */
|
Chris@0
|
185 const PROXY = 'proxy';
|
Chris@0
|
186
|
Chris@0
|
187 /**
|
Chris@0
|
188 * query: (array|string) Associative array of query string values to add
|
Chris@0
|
189 * to the request. This option uses PHP's http_build_query() to create
|
Chris@0
|
190 * the string representation. Pass a string value if you need more
|
Chris@0
|
191 * control than what this method provides
|
Chris@0
|
192 */
|
Chris@0
|
193 const QUERY = 'query';
|
Chris@0
|
194
|
Chris@0
|
195 /**
|
Chris@0
|
196 * sink: (resource|string|StreamInterface) Where the data of the
|
Chris@0
|
197 * response is written to. Defaults to a PHP temp stream. Providing a
|
Chris@0
|
198 * string will write data to a file by the given name.
|
Chris@0
|
199 */
|
Chris@0
|
200 const SINK = 'sink';
|
Chris@0
|
201
|
Chris@0
|
202 /**
|
Chris@0
|
203 * synchronous: (bool) Set to true to inform HTTP handlers that you intend
|
Chris@0
|
204 * on waiting on the response. This can be useful for optimizations. Note
|
Chris@0
|
205 * that a promise is still returned if you are using one of the async
|
Chris@0
|
206 * client methods.
|
Chris@0
|
207 */
|
Chris@0
|
208 const SYNCHRONOUS = 'synchronous';
|
Chris@0
|
209
|
Chris@0
|
210 /**
|
Chris@0
|
211 * ssl_key: (array|string) Specify the path to a file containing a private
|
Chris@0
|
212 * SSL key in PEM format. If a password is required, then set to an array
|
Chris@0
|
213 * containing the path to the SSL key in the first array element followed
|
Chris@0
|
214 * by the password required for the certificate in the second element.
|
Chris@0
|
215 */
|
Chris@0
|
216 const SSL_KEY = 'ssl_key';
|
Chris@0
|
217
|
Chris@0
|
218 /**
|
Chris@0
|
219 * stream: Set to true to attempt to stream a response rather than
|
Chris@0
|
220 * download it all up-front.
|
Chris@0
|
221 */
|
Chris@0
|
222 const STREAM = 'stream';
|
Chris@0
|
223
|
Chris@0
|
224 /**
|
Chris@0
|
225 * verify: (bool|string, default=true) Describes the SSL certificate
|
Chris@0
|
226 * verification behavior of a request. Set to true to enable SSL
|
Chris@0
|
227 * certificate verification using the system CA bundle when available
|
Chris@0
|
228 * (the default). Set to false to disable certificate verification (this
|
Chris@0
|
229 * is insecure!). Set to a string to provide the path to a CA bundle on
|
Chris@0
|
230 * disk to enable verification using a custom certificate.
|
Chris@0
|
231 */
|
Chris@0
|
232 const VERIFY = 'verify';
|
Chris@0
|
233
|
Chris@0
|
234 /**
|
Chris@0
|
235 * timeout: (float, default=0) Float describing the timeout of the
|
Chris@0
|
236 * request in seconds. Use 0 to wait indefinitely (the default behavior).
|
Chris@0
|
237 */
|
Chris@0
|
238 const TIMEOUT = 'timeout';
|
Chris@0
|
239
|
Chris@0
|
240 /**
|
Chris@0
|
241 * read_timeout: (float, default=default_socket_timeout ini setting) Float describing
|
Chris@0
|
242 * the body read timeout, for stream requests.
|
Chris@0
|
243 */
|
Chris@0
|
244 const READ_TIMEOUT = 'read_timeout';
|
Chris@0
|
245
|
Chris@0
|
246 /**
|
Chris@0
|
247 * version: (float) Specifies the HTTP protocol version to attempt to use.
|
Chris@0
|
248 */
|
Chris@0
|
249 const VERSION = 'version';
|
Chris@0
|
250
|
Chris@0
|
251 /**
|
Chris@0
|
252 * force_ip_resolve: (bool) Force client to use only ipv4 or ipv6 protocol
|
Chris@0
|
253 */
|
Chris@0
|
254 const FORCE_IP_RESOLVE = 'force_ip_resolve';
|
Chris@0
|
255 }
|