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