RequestOptions.php 11 KB

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