No Description

RequestOptions.php 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. * @link 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=true) Set to false to disable 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. 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. const AUTH = 'auth';
  42. /**
  43. * body: (string|null|callable|iterator|object) Body to send in the
  44. * request.
  45. */
  46. 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. 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. 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. * indefinitely (the default behavior).
  67. */
  68. const CONNECT_TIMEOUT = 'connect_timeout';
  69. /**
  70. * debug: (bool|resource) Set to true or set to a PHP stream returned by
  71. * fopen() enable debug output with the HTTP handler used to send a
  72. * request.
  73. */
  74. const DEBUG = 'debug';
  75. /**
  76. * decode_content: (bool, default=true) Specify whether or not
  77. * Content-Encoding responses (gzip, deflate, etc.) are automatically
  78. * decoded.
  79. */
  80. const DECODE_CONTENT = 'decode_content';
  81. /**
  82. * delay: (int) The amount of time to delay before sending in milliseconds.
  83. */
  84. const DELAY = 'delay';
  85. /**
  86. * expect: (bool|integer) Controls the behavior of the
  87. * "Expect: 100-Continue" header.
  88. *
  89. * Set to `true` to enable the "Expect: 100-Continue" header for all
  90. * requests that sends a body. Set to `false` to disable the
  91. * "Expect: 100-Continue" header for all requests. Set to a number so that
  92. * the size of the payload must be greater than the number in order to send
  93. * the Expect header. Setting to a number will send the Expect header for
  94. * all requests in which the size of the payload cannot be determined or
  95. * where the body is not rewindable.
  96. *
  97. * By default, Guzzle will add the "Expect: 100-Continue" header when the
  98. * size of the body of a request is greater than 1 MB and a request is
  99. * using HTTP/1.1.
  100. */
  101. const EXPECT = 'expect';
  102. /**
  103. * form_params: (array) Associative array of form field names to values
  104. * where each value is a string or array of strings. Sets the Content-Type
  105. * header to application/x-www-form-urlencoded when no Content-Type header
  106. * is already present.
  107. */
  108. const FORM_PARAMS = 'form_params';
  109. /**
  110. * headers: (array) Associative array of HTTP headers. Each value MUST be
  111. * a string or array of strings.
  112. */
  113. const HEADERS = 'headers';
  114. /**
  115. * http_errors: (bool, default=true) Set to false to disable exceptions
  116. * when a non- successful HTTP response is received. By default,
  117. * exceptions will be thrown for 4xx and 5xx responses. This option only
  118. * works if your handler has the `httpErrors` middleware.
  119. */
  120. const HTTP_ERRORS = 'http_errors';
  121. /**
  122. * json: (mixed) Adds JSON data to a request. The provided value is JSON
  123. * encoded and a Content-Type header of application/json will be added to
  124. * the request if no Content-Type header is already present.
  125. */
  126. const JSON = 'json';
  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. * on_headers: (callable) A callable that is invoked when the HTTP headers
  139. * of the response have been received but the body has not yet begun to
  140. * download.
  141. */
  142. const ON_HEADERS = 'on_headers';
  143. /**
  144. * on_stats: (callable) allows you to get access to transfer statistics of
  145. * a request and access the lower level transfer details of the handler
  146. * associated with your client. ``on_stats`` is a callable that is invoked
  147. * when a handler has finished sending a request. The callback is invoked
  148. * with transfer statistics about the request, the response received, or
  149. * the error encountered. Included in the data is the total amount of time
  150. * taken to send the request.
  151. */
  152. const ON_STATS = 'on_stats';
  153. /**
  154. * progress: (callable) Defines a function to invoke when transfer
  155. * progress is made. The function accepts the following positional
  156. * arguments: the total number of bytes expected to be downloaded, the
  157. * number of bytes downloaded so far, the number of bytes expected to be
  158. * uploaded, the number of bytes uploaded so far.
  159. */
  160. const PROGRESS = 'progress';
  161. /**
  162. * proxy: (string|array) Pass a string to specify an HTTP proxy, or an
  163. * array to specify different proxies for different protocols (where the
  164. * key is the protocol and the value is a proxy string).
  165. */
  166. const PROXY = 'proxy';
  167. /**
  168. * query: (array|string) Associative array of query string values to add
  169. * to the request. This option uses PHP's http_build_query() to create
  170. * the string representation. Pass a string value if you need more
  171. * control than what this method provides
  172. */
  173. const QUERY = 'query';
  174. /**
  175. * sink: (resource|string|StreamInterface) Where the data of the
  176. * response is written to. Defaults to a PHP temp stream. Providing a
  177. * string will write data to a file by the given name.
  178. */
  179. const SINK = 'sink';
  180. /**
  181. * synchronous: (bool) Set to true to inform HTTP handlers that you intend
  182. * on waiting on the response. This can be useful for optimizations. Note
  183. * that a promise is still returned if you are using one of the async
  184. * client methods.
  185. */
  186. const SYNCHRONOUS = 'synchronous';
  187. /**
  188. * ssl_key: (array|string) Specify the path to a file containing a private
  189. * SSL key in PEM format. If a password is required, then set to an array
  190. * containing the path to the SSL key in the first array element followed
  191. * by the password required for the certificate in the second element.
  192. */
  193. const SSL_KEY = 'ssl_key';
  194. /**
  195. * stream: Set to true to attempt to stream a response rather than
  196. * download it all up-front.
  197. */
  198. const STREAM = 'stream';
  199. /**
  200. * verify: (bool|string, default=true) Describes the SSL certificate
  201. * verification behavior of a request. Set to true to enable SSL
  202. * certificate verification using the system CA bundle when available
  203. * (the default). Set to false to disable certificate verification (this
  204. * is insecure!). Set to a string to provide the path to a CA bundle on
  205. * disk to enable verification using a custom certificate.
  206. */
  207. const VERIFY = 'verify';
  208. /**
  209. * timeout: (float, default=0) Float describing the timeout of the
  210. * request in seconds. Use 0 to wait indefinitely (the default behavior).
  211. */
  212. const TIMEOUT = 'timeout';
  213. /**
  214. * version: (float) Specifies the HTTP protocol version to attempt to use.
  215. */
  216. const VERSION = 'version';
  217. }