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