vendor/guzzlehttp/guzzle/src/RequestOptions.php
434 lines · 20231 bytes
1<?php
2
3namespace GuzzleHttp;
4
5/**
6 * This class contains a list of built-in Guzzle request options.
7 *
8 * @see https://github.com/guzzle/guzzle/blob/7.16/docs/request-options.md
9 */
10final class RequestOptions
11{
12 /**
13 * allow_redirects: (bool|array) Controls redirect behavior. Pass false
14 * to disable redirects, pass true to enable redirects, pass an
15 * associative to provide custom redirect settings. Defaults to "false".
16 * This option only works if your handler has the RedirectMiddleware. When
17 * passing an associative array, you can provide the following key value
18 * pairs:
19 *
20 * - max: (int, default=5) maximum number of allowed redirects.
21 * - strict: (bool, default=false) Set to true to use strict redirects
22 * meaning redirect POST requests with POST requests vs. doing what most
23 * browsers do which is redirect POST requests with GET requests. The
24 * QUERY method keeps its method and body across non-strict 301 and 302
25 * redirects, and a 303 redirect is followed with a body-less GET.
26 * - referer: (bool, default=false) Set to true to enable the Referer
27 * header.
28 * - protocols: (non-empty-array<array-key, string>, default=['http', 'https'])
29 * Allowed redirect protocols. Redirect matching is case-sensitive; use
30 * "http" and "https".
31 * - on_redirect: (callable) PHP callable that is invoked when a redirect
32 * is encountered. The callable is invoked with the request, the redirect
33 * response that was received, and the effective URI. Any return value
34 * from the on_redirect function is ignored.
35 * - track_redirects: (bool, default=false) Track redirected URI and status
36 * history in response headers.
37 */
38 public const ALLOW_REDIRECTS = 'allow_redirects';
39
40 /**
41 * auth: (array{0: string, 1: string, 2?: string|null}|string|false|null)
42 * Pass an array of HTTP authentication parameters to use with the request.
43 * The array must contain the username in index [0], the password in index
44 * [1], and you can optionally provide a built-in authentication type in
45 * index [2]. Pass false or null to disable authentication for a request.
46 * String values are passed through for custom handlers.
47 */
48 public const AUTH = 'auth';
49
50 /**
51 * body: (resource|string|null|int|float|bool|\Psr\Http\Message\StreamInterface|(callable&object)|\Iterator|\Stringable)
52 * Body to send in the request. Callable arrays are arrays, and arrays are
53 * not valid body values in Guzzle.
54 */
55 public const BODY = 'body';
56
57 /**
58 * cert: (string|array{0: string, 1?: string|null}) Set to a string to
59 * specify the path to a client certificate file. PEM is the default
60 * certificate format. If a password is required, set cert to an array
61 * containing the certificate path in the first array element followed by
62 * the certificate password in the second array element. A null password is
63 * treated the same as omitting it. Use cert_type to specify another
64 * supported certificate format.
65 */
66 public const CERT = 'cert';
67
68 /**
69 * cert_type: (string) Specify the SSL client certificate file type.
70 */
71 public const CERT_TYPE = 'cert_type';
72
73 /**
74 * cookies: (false|GuzzleHttp\Cookie\CookieJarInterface, default=false)
75 * Specifies whether or not cookies are used in a request or what cookie
76 * jar to use or what cookies to send. This option only works if your
77 * handler has the `cookie` middleware. Valid values are `false` and
78 * an instance of {@see Cookie\CookieJarInterface}.
79 */
80 public const COOKIES = 'cookies';
81
82 /**
83 * connect_timeout: (int|float, default=0) Number of seconds to wait while
84 * trying to connect to a server. Use 0 to wait 300 seconds (the default
85 * behavior).
86 */
87 public const CONNECT_TIMEOUT = 'connect_timeout';
88
89 /**
90 * crypto_method: (int) A value describing the minimum TLS protocol
91 * version to use.
92 *
93 * This setting must be set to one of the
94 * ``STREAM_CRYPTO_METHOD_TLS*_CLIENT`` constants. PHP 7.4 or higher is
95 * required in order to use TLS 1.3, and cURL 7.34.0 or higher is required
96 * in order to specify a crypto method, with cURL 7.52.0 or higher being
97 * required to use TLS 1.3.
98 */
99 public const CRYPTO_METHOD = 'crypto_method';
100
101 /**
102 * crypto_method_max: (int) A value describing the maximum TLS protocol
103 * version to use.
104 *
105 * This setting must be set to one of the
106 * ``STREAM_CRYPTO_METHOD_TLS*_CLIENT`` constants. On the stream handler,
107 * PHP 7.3 or higher is required to set a maximum TLS version, and PHP 7.4
108 * or higher is required to use TLS 1.3. cURL 7.54.0 or higher is required
109 * in order to specify a maximum TLS version with the cURL handler.
110 */
111 public const CRYPTO_METHOD_MAX = 'crypto_method_max';
112
113 /**
114 * curl: (array) Raw cURL options to apply when using a built-in cURL handler.
115 */
116 public const CURL = 'curl';
117
118 /**
119 * debug: (bool|resource) Set to true or set to a PHP stream returned by
120 * fopen() enable debug output with the HTTP handler used to send a
121 * request.
122 */
123 public const DEBUG = 'debug';
124
125 /**
126 * decode_content: (bool|string, default=true) Specify whether or not
127 * Content-Encoding responses (gzip, deflate, etc.) are automatically
128 * decoded.
129 */
130 public const DECODE_CONTENT = 'decode_content';
131
132 /**
133 * delay: (int|float) The amount of time to delay before sending in
134 * milliseconds.
135 */
136 public const DELAY = 'delay';
137
138 /**
139 * expect: (bool|integer) Controls the behavior of the
140 * "Expect: 100-Continue" header.
141 *
142 * Set to `true` to enable the "Expect: 100-Continue" header for all
143 * requests that sends a body. Set to `false` to disable the
144 * "Expect: 100-Continue" header for all requests. Set to a number so that
145 * the size of the payload must be greater than the number in order to send
146 * the Expect header. Setting to a number will send the Expect header for
147 * all requests in which the size of the payload cannot be determined or
148 * where the body is not rewindable.
149 *
150 * By default, Guzzle will add the "Expect: 100-Continue" header when the
151 * size of the body of a request is greater than 1 MB and a request is
152 * using HTTP/1.1.
153 */
154 public const EXPECT = 'expect';
155
156 /**
157 * form_params: (array<array-key, string|int|float|bool|null|array>)
158 * Associative array of form field names to scalar, null, or nested array
159 * values. Sets the Content-Type header to application/x-www-form-urlencoded
160 * when no Content-Type header is already present.
161 */
162 public const FORM_PARAMS = 'form_params';
163
164 /**
165 * headers: (array<array-key, string|non-empty-array<array-key, string>>|null)
166 * Associative array of HTTP headers. Each value MUST be a string or non-empty
167 * array of strings.
168 */
169 public const HEADERS = 'headers';
170
171 /**
172 * http_errors: (bool, default=true) Set to false to disable exceptions
173 * when a non- successful HTTP response is received. By default,
174 * exceptions will be thrown for 4xx and 5xx responses. This option only
175 * works if your handler has the `httpErrors` middleware.
176 */
177 public const HTTP_ERRORS = 'http_errors';
178
179 /**
180 * idn_conversion: (bool|int|null, default=false) A combination of IDNA_*
181 * constants for PHP's idn_to_ascii() function. Set to false or null to
182 * disable IDN support, or to true to use the default configuration
183 * (IDNA_DEFAULT constant).
184 */
185 public const IDN_CONVERSION = 'idn_conversion';
186
187 /**
188 * json: (mixed) Adds JSON data to a request. The provided value is JSON
189 * encoded and a Content-Type header of application/json will be added to
190 * the request if no Content-Type header is already present.
191 */
192 public const JSON = 'json';
193
194 /**
195 * multipart: (array) Array of part arrays, each containing a required
196 * "name" key mapping to the string or integer form field name, a required
197 * "contents" key mapping to any non-array value accepted by PSR-7
198 * Utils::streamFor() or a nested array of field values, an optional
199 * "headers" array of string custom header values, and an optional
200 * "filename" key mapping to a string to send as the filename in the part.
201 * "headers" and "filename" cannot be used when "contents" is an array.
202 */
203 public const MULTIPART = 'multipart';
204
205 /**
206 * multiplex: (string) Controls how a request sent through a built-in
207 * cURL handler relates to shared, multiplexed connections: how an HTTP/2
208 * request pursues one, or, with Multiplexing::NONE, whether the transfer
209 * may share its connection at all. When the option is not set,
210 * multiplexing is left to libcurl: nothing waits, and established
211 * multiplex-capable connections are still shared. Use
212 * Multiplexing::EAGER to explicitly never wait for pending connections,
213 * Multiplexing::WAIT to wait on libcurl-eligible pending connections with
214 * CURLOPT_PIPEWAIT, normally to the same origin,
215 * Multiplexing::REQUIRE_EAGER to fail unless a multiplexed protocol is
216 * guaranteed while dialing eagerly, or Multiplexing::REQUIRE_WAIT for the
217 * same guarantee while also waiting on pending connections. The required
218 * modes require a handler that permits actual multiplexing, not merely a
219 * multiplexed protocol, and are rejected on a Multiplexing::NONE handler.
220 * The stream handler ignores EAGER and WAIT, and rejects the required
221 * family; CurlHandler has no multi handle to multiplex over. Explicit
222 * modes reject deprecated raw cURL options they conflict with: the
223 * required family cannot be combined with a raw CURLOPT_HTTP_VERSION,
224 * CURLOPT_URL, or CURLOPT_FOLLOWLOCATION; no explicit mode can be
225 * combined with a raw CURLOPT_PIPEWAIT on the CurlMultiHandler; and
226 * Multiplexing::NONE on a CurlMultiHandler that permits multiplexing
227 * cannot be combined with the raw CURLOPT_HTTP_VERSION, CURLOPT_HTTPAUTH
228 * (including the "auth" request option's "digest" and "ntlm" modes,
229 * which set it), CURLOPT_PROXYAUTH, CURLOPT_FOLLOWLOCATION,
230 * CURLOPT_HTTPHEADER, CURLOPT_ALTSVC, CURLOPT_ALTSVC_CTRL, or
231 * CURLOPT_PROXYTYPE cURL options. The required family also
232 * rejects final CURLOPT_HTTPAUTH masks that permit NTLM, which libcurl
233 * retries over HTTP/1.1. The required family validates its cleartext
234 * proxy rule against the final cURL configuration, after raw options
235 * such as CURLOPT_PROXY and CURLOPT_PRE_PROXY are applied; only the
236 * exact raw CURLOPT_NOPROXY wildcard '*' disables the primary proxy and
237 * pre-proxy there, and raw host-specific patterns are conservatively
238 * treated as leaving them active. These rejections are
239 * configuration-conflict checks, not remote security checks.
240 *
241 * Multiplexing::NONE disables multiplexing for a whole handler when
242 * passed as the "multiplex" client configuration option, which
243 * configures the default handler and also becomes the default request
244 * option, or, when constructing a handler directly, as the
245 * CurlMultiHandler "multiplex" constructor option. A handler
246 * configured with Multiplexing::NONE rejects explicitly requested wait
247 * modes as a configuration conflict when the transfer would actually
248 * wait, and always rejects the required modes, because they require a
249 * handler that permits actual multiplexing, not merely a multiplexed
250 * protocol. As a request option value, Multiplexing::NONE guarantees the
251 * transfer does not share its connection with any concurrent transfer.
252 * Multiplexing::NONE does not force HTTP/1.1: on a Multiplexing::NONE
253 * handler, HTTP/2 still negotiates and each transfer keeps its
254 * connection to itself.
255 *
256 * The request option value is accepted exactly where the guarantee
257 * holds and can be verified: on a CurlMultiHandler configured with
258 * Multiplexing::NONE, for requests whose declared protocol version is
259 * HTTP/1.x, on CurlHandler, and on the stream handler, which never
260 * multiplexes. An HTTP/2 request with a Multiplexing::NONE request
261 * option is rejected on a CurlMultiHandler that permits multiplexing.
262 * On a CurlMultiHandler that permits multiplexing, Multiplexing::NONE
263 * is also rejected with a custom "handle_factory", alongside a raw
264 * CURLMOPT_PIPELINING cURL multi option, and combined with the raw
265 * CURLOPT_HTTP_VERSION, CURLOPT_HTTPAUTH (including the "auth" request
266 * option's "digest" and "ntlm" modes, which set it), CURLOPT_PROXYAUTH,
267 * CURLOPT_FOLLOWLOCATION, CURLOPT_HTTPHEADER, CURLOPT_ALTSVC,
268 * CURLOPT_ALTSVC_CTRL, or CURLOPT_PROXYTYPE cURL options. It is also
269 * rejected when the request carries an Expect: 100-continue header (its
270 * 417 retries select connections outside the safeguards; remove an
271 * explicitly supplied header, or set the "expect" request option to
272 * false to prevent it being added automatically).
273 *
274 * On a client whose multi handler permits multiplexing, the ordinary
275 * non-streaming default stack - both cURL handlers available and no
276 * connection caps forcing multi-only routing - runs synchronous
277 * requests on the CurlHandler path, which satisfies the guarantee for
278 * any protocol version, while asynchronous requests run on the
279 * CurlMultiHandler, so an HTTP/2 request with Multiplexing::NONE
280 * succeeds synchronously and is rejected asynchronously on the same
281 * client. Keep-alive reuse between consecutive transfers is
282 * unaffected, except on libcurl versions below 7.77.0 and from 8.11.0
283 * through 8.12.1, where an accepted HTTP/1.x request on a multiplexing
284 * CurlMultiHandler forces a fresh connection. Custom handlers receive
285 * the "multiplex" option unchanged: its semantics are handler-defined,
286 * Guzzle does not guarantee it is honored, and a client-level
287 * Multiplexing::NONE with a custom handler flows to it as a default
288 * request option without client-side enforcement.
289 */
290 public const MULTIPLEX = 'multiplex';
291
292 /**
293 * on_headers: (callable) A callable that is invoked when the HTTP headers
294 * of the response have been received but the body has not yet begun to
295 * download.
296 */
297 public const ON_HEADERS = 'on_headers';
298
299 /**
300 * on_stats: (callable) allows you to get access to transfer statistics of
301 * a request and access the lower level transfer details of the handler
302 * associated with your client. ``on_stats`` is a callable that is invoked
303 * when a handler has finished sending a request. The callback is invoked
304 * with transfer statistics about the request, the response received, or
305 * the error encountered. Included in the data is the total amount of time
306 * taken to send the request.
307 */
308 public const ON_STATS = 'on_stats';
309
310 /**
311 * on_trailers: (callable) A callable that is invoked by the built-in cURL
312 * handlers once per successful transfer, after the response body has been
313 * received, with an associative array of the parsed HTTP trailers followed
314 * by the response. Trailer field names are lowercased and grouped
315 * case-insensitively; values keep their wire order. Malformed trailer
316 * field lines are discarded before parsing. Trailer fields are reported
317 * separately from response headers and are never merged into the response.
318 */
319 public const ON_TRAILERS = 'on_trailers';
320
321 /**
322 * progress: (callable) Defines a function to invoke when transfer
323 * progress is made. The function accepts the following positional
324 * arguments: the total number of bytes expected to be downloaded, the
325 * number of bytes downloaded so far, the number of bytes expected to be
326 * uploaded, the number of bytes uploaded so far.
327 */
328 public const PROGRESS = 'progress';
329
330 /**
331 * protocols: (non-empty-array<array-key, string>, default=['http', 'https'])
332 * Allowed URI schemes. Built-in handlers accept only the case-sensitive
333 * values "http" and "https".
334 */
335 public const PROTOCOLS = 'protocols';
336
337 /**
338 * proxy: (string|array) Pass a string to specify an HTTP proxy, or an
339 * array to specify different proxies for different protocols (where the
340 * key is the protocol and the value is a proxy string or null). Provide a
341 * "no" key as a comma-delimited string, array of strings, or null to
342 * specify hosts or host-and-port pairs that should not be proxied.
343 */
344 public const PROXY = 'proxy';
345
346 /**
347 * query: (array<array-key, mixed>|string) Associative array of query string
348 * values to add to the request. This option uses PHP's http_build_query()
349 * to create the string representation. Pass a string value if you need
350 * more control than what this method provides
351 */
352 public const QUERY = 'query';
353
354 /**
355 * sink: (resource|string|\Psr\Http\Message\StreamInterface) Where the data
356 * of the response is written to. Defaults to a PHP temp stream. Providing
357 * a string will write data to a file by the given name.
358 */
359 public const SINK = 'sink';
360
361 /**
362 * synchronous: (bool) Set to true to inform HTTP handlers that you intend
363 * on waiting on the response. This can be useful for optimizations. Note
364 * that a promise is still returned if you are using one of the async
365 * client methods.
366 */
367 public const SYNCHRONOUS = 'synchronous';
368
369 /**
370 * ssl_key: (array{0: string, 1?: string|null}|string) Specify the path to
371 * a private SSL key file. PEM is the default private key format. If a
372 * password is required, set ssl_key to an array containing the key path in
373 * the first array element followed by the key password in the second
374 * element. A null password is treated the same as omitting it. Use
375 * ssl_key_type to specify another supported key format.
376 */
377 public const SSL_KEY = 'ssl_key';
378
379 /**
380 * ssl_key_type: (string) Specify the SSL private key file type.
381 */
382 public const SSL_KEY_TYPE = 'ssl_key_type';
383
384 /**
385 * stream: (bool) Set to true to attempt to stream a response rather than
386 * download it all up-front.
387 */
388 public const STREAM = 'stream';
389
390 /**
391 * stream_context: (array) PHP stream context options to merge into the
392 * context used by the built-in stream handler.
393 */
394 public const STREAM_CONTEXT = 'stream_context';
395
396 /**
397 * verify: (bool|string, default=true) Describes the SSL certificate
398 * verification behavior of a request. Set to true to enable SSL
399 * certificate verification using the system CA bundle when available
400 * (the default). Set to false to disable certificate verification (this
401 * is insecure!). Set to a string to provide the path to a CA bundle on
402 * disk to enable verification using a custom certificate.
403 */
404 public const VERIFY = 'verify';
405
406 /**
407 * timeout: (int|float, default=0) Number describing the timeout of the
408 * request in seconds. Use 0 to wait indefinitely (the default behavior).
409 */
410 public const TIMEOUT = 'timeout';
411
412 /**
413 * read_timeout: (int|float, default=default_socket_timeout ini setting)
414 * Number describing the body read timeout, for stream requests.
415 */
416 public const READ_TIMEOUT = 'read_timeout';
417
418 /**
419 * retries: (int) Current retry count used by the retry middleware.
420 */
421 public const RETRIES = 'retries';
422
423 /**
424 * version: (string|int|float) Specifies the HTTP protocol version to attempt
425 * to use.
426 */
427 public const VERSION = 'version';
428
429 /**
430 * force_ip_resolve: (string) Set to "v4" to force IPv4 resolution or "v6"
431 * for IPv6 resolution when supported by the handler.
432 */
433 public const FORCE_IP_RESOLVE = 'force_ip_resolve';
434}