ClientInterface.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace GuzzleHttp;
  3. use GuzzleHttp\Exception\GuzzleException;
  4. use GuzzleHttp\Promise\PromiseInterface;
  5. use Psr\Http\Message\RequestInterface;
  6. use Psr\Http\Message\ResponseInterface;
  7. use Psr\Http\Message\UriInterface;
  8. /**
  9. * Client interface for sending HTTP requests.
  10. */
  11. interface ClientInterface
  12. {
  13. /**
  14. * The Guzzle major version.
  15. */
  16. public const MAJOR_VERSION = 7;
  17. /**
  18. * Send an HTTP request.
  19. *
  20. * @param RequestInterface $request Request to send
  21. * @param array $options Request options to apply to the given
  22. * request and to the transfer.
  23. *
  24. * @throws GuzzleException
  25. */
  26. public function send(RequestInterface $request, array $options = []): ResponseInterface;
  27. /**
  28. * Asynchronously send an HTTP request.
  29. *
  30. * @param RequestInterface $request Request to send
  31. * @param array $options Request options to apply to the given
  32. * request and to the transfer.
  33. */
  34. public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface;
  35. /**
  36. * Create and send an HTTP request.
  37. *
  38. * Use an absolute path to override the base path of the client, or a
  39. * relative path to append to the base path of the client. The URL can
  40. * contain the query string as well.
  41. *
  42. * @param string $method HTTP method.
  43. * @param string|UriInterface $uri URI object or string.
  44. * @param array $options Request options to apply.
  45. *
  46. * @throws GuzzleException
  47. */
  48. public function request(string $method, $uri, array $options = []): ResponseInterface;
  49. /**
  50. * Create and send an asynchronous HTTP request.
  51. *
  52. * Use an absolute path to override the base path of the client, or a
  53. * relative path to append to the base path of the client. The URL can
  54. * contain the query string as well. Use an array to provide a URL
  55. * template and additional variables to use in the URL template expansion.
  56. *
  57. * @param string $method HTTP method
  58. * @param string|UriInterface $uri URI object or string.
  59. * @param array $options Request options to apply.
  60. */
  61. public function requestAsync(string $method, $uri, array $options = []): PromiseInterface;
  62. /**
  63. * Get a client configuration option.
  64. *
  65. * These options include default request options of the client, a "handler"
  66. * (if utilized by the concrete client), and a "base_uri" if utilized by
  67. * the concrete client.
  68. *
  69. * @param string|null $option The config option to retrieve.
  70. *
  71. * @return mixed
  72. *
  73. * @deprecated ClientInterface::getConfig will be removed in guzzlehttp/guzzle:8.0.
  74. */
  75. public function getConfig(?string $option = null);
  76. }