RequestOptions.php 11 KB

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