371 lines
14 KiB
PHP
371 lines
14 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace GuzzleHttp;
|
|
|
|
use GuzzleHttp\Cookie\CookieJarInterface;
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
use GuzzleHttp\Promise\PromiseInterface;
|
|
use Psr\Http\Message\RequestFactoryInterface;
|
|
use Psr\Http\Message\RequestInterface;
|
|
use Psr\Http\Message\ResponseFactoryInterface;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Psr\Http\Message\StreamFactoryInterface;
|
|
use Psr\Http\Message\StreamInterface;
|
|
use Psr\Http\Message\UriFactoryInterface;
|
|
use Psr\Http\Message\UriInterface;
|
|
|
|
/**
|
|
* Client interface for sending HTTP requests.
|
|
*/
|
|
interface ClientInterface
|
|
{
|
|
/**
|
|
* The Guzzle major version.
|
|
*/
|
|
public const MAJOR_VERSION = 8;
|
|
|
|
/**
|
|
* Send an HTTP request.
|
|
*
|
|
* @param RequestInterface $request Request to send
|
|
* @param array{
|
|
* base_uri?: string|UriInterface,
|
|
* allow_redirects?: bool|array{
|
|
* max?: int,
|
|
* strict?: bool,
|
|
* referer?: bool,
|
|
* protocols?: non-empty-array<array-key, string>,
|
|
* on_redirect?: callable(RequestInterface, ResponseInterface, UriInterface): mixed,
|
|
* track_redirects?: bool
|
|
* },
|
|
* auth?: array{
|
|
* 0: string,
|
|
* 1: string,
|
|
* 2?: string|null
|
|
* }|string|false|null,
|
|
* body?: resource|string|null|StreamInterface|(callable&object)|\Iterator|\Stringable,
|
|
* cert?: string|array{
|
|
* 0: string,
|
|
* 1?: string|null
|
|
* },
|
|
* cert_type?: string,
|
|
* connect_timeout?: int|float,
|
|
* cookies?: false|CookieJarInterface,
|
|
* crypto_method?: int,
|
|
* crypto_method_max?: int,
|
|
* debug?: bool|resource,
|
|
* decode_content?: bool|string,
|
|
* delay?: int|float,
|
|
* expect?: bool|int,
|
|
* form_params?: array<array-key, string|int|float|bool|null|array>,
|
|
* force_ip_resolve?: string,
|
|
* headers?: array<array-key, string|non-empty-array<array-key, string>>|null,
|
|
* http_errors?: bool,
|
|
* idn_conversion?: bool|int|null,
|
|
* json?: mixed,
|
|
* multipart?: array<array-key, array{
|
|
* name: string|int,
|
|
* contents: mixed,
|
|
* headers?: array<array-key, string>,
|
|
* filename?: string
|
|
* }>,
|
|
* multiplex?: string,
|
|
* on_headers?: callable(ResponseInterface, RequestInterface): mixed,
|
|
* on_stats?: callable(TransferStats): mixed,
|
|
* on_trailers?: callable(array<string, list<string>>, ResponseInterface, RequestInterface): mixed,
|
|
* progress?: callable(int, int, int, int): mixed,
|
|
* protocols?: non-empty-array<array-key, string>,
|
|
* proxy?: string|array{
|
|
* http?: string|null,
|
|
* https?: string|null,
|
|
* no?: string|array<array-key, string>|null
|
|
* },
|
|
* query?: array<array-key, mixed>|string,
|
|
* read_timeout?: int|float,
|
|
* retries?: int,
|
|
* request_factory?: RequestFactoryInterface,
|
|
* response_factory?: ResponseFactoryInterface,
|
|
* sink?: resource|string|StreamInterface,
|
|
* ssl_key?: string|array{
|
|
* 0: string,
|
|
* 1?: string|null
|
|
* },
|
|
* ssl_key_type?: string,
|
|
* stream?: bool,
|
|
* stream_factory?: StreamFactoryInterface,
|
|
* stream_context?: array<array-key, mixed>,
|
|
* synchronous?: bool,
|
|
* timeout?: int|float,
|
|
* uri_factory?: UriFactoryInterface,
|
|
* verify?: bool|string,
|
|
* version?: string|int|float,
|
|
* curl?: array<int|string, mixed>,
|
|
* ...
|
|
* } $options Request options to apply to the given request and to the transfer.
|
|
*
|
|
* @throws GuzzleException
|
|
*/
|
|
public function send(RequestInterface $request, array $options = []): ResponseInterface;
|
|
|
|
/**
|
|
* Asynchronously send an HTTP request.
|
|
*
|
|
* @param RequestInterface $request Request to send
|
|
* @param array{
|
|
* base_uri?: string|UriInterface,
|
|
* allow_redirects?: bool|array{
|
|
* max?: int,
|
|
* strict?: bool,
|
|
* referer?: bool,
|
|
* protocols?: non-empty-array<array-key, string>,
|
|
* on_redirect?: callable(RequestInterface, ResponseInterface, UriInterface): mixed,
|
|
* track_redirects?: bool
|
|
* },
|
|
* auth?: array{
|
|
* 0: string,
|
|
* 1: string,
|
|
* 2?: string|null
|
|
* }|string|false|null,
|
|
* body?: resource|string|null|StreamInterface|(callable&object)|\Iterator|\Stringable,
|
|
* cert?: string|array{
|
|
* 0: string,
|
|
* 1?: string|null
|
|
* },
|
|
* cert_type?: string,
|
|
* connect_timeout?: int|float,
|
|
* cookies?: false|CookieJarInterface,
|
|
* crypto_method?: int,
|
|
* crypto_method_max?: int,
|
|
* debug?: bool|resource,
|
|
* decode_content?: bool|string,
|
|
* delay?: int|float,
|
|
* expect?: bool|int,
|
|
* form_params?: array<array-key, string|int|float|bool|null|array>,
|
|
* force_ip_resolve?: string,
|
|
* headers?: array<array-key, string|non-empty-array<array-key, string>>|null,
|
|
* http_errors?: bool,
|
|
* idn_conversion?: bool|int|null,
|
|
* json?: mixed,
|
|
* multipart?: array<array-key, array{
|
|
* name: string|int,
|
|
* contents: mixed,
|
|
* headers?: array<array-key, string>,
|
|
* filename?: string
|
|
* }>,
|
|
* multiplex?: string,
|
|
* on_headers?: callable(ResponseInterface, RequestInterface): mixed,
|
|
* on_stats?: callable(TransferStats): mixed,
|
|
* on_trailers?: callable(array<string, list<string>>, ResponseInterface, RequestInterface): mixed,
|
|
* progress?: callable(int, int, int, int): mixed,
|
|
* protocols?: non-empty-array<array-key, string>,
|
|
* proxy?: string|array{
|
|
* http?: string|null,
|
|
* https?: string|null,
|
|
* no?: string|array<array-key, string>|null
|
|
* },
|
|
* query?: array<array-key, mixed>|string,
|
|
* read_timeout?: int|float,
|
|
* retries?: int,
|
|
* request_factory?: RequestFactoryInterface,
|
|
* response_factory?: ResponseFactoryInterface,
|
|
* sink?: resource|string|StreamInterface,
|
|
* ssl_key?: string|array{
|
|
* 0: string,
|
|
* 1?: string|null
|
|
* },
|
|
* ssl_key_type?: string,
|
|
* stream?: bool,
|
|
* stream_factory?: StreamFactoryInterface,
|
|
* stream_context?: array<array-key, mixed>,
|
|
* synchronous?: bool,
|
|
* timeout?: int|float,
|
|
* uri_factory?: UriFactoryInterface,
|
|
* verify?: bool|string,
|
|
* version?: string|int|float,
|
|
* curl?: array<int|string, mixed>,
|
|
* ...
|
|
* } $options Request options to apply to the given request and to the transfer.
|
|
*
|
|
* @return PromiseInterface<ResponseInterface, mixed>
|
|
*/
|
|
public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface;
|
|
|
|
/**
|
|
* Create and send an HTTP request.
|
|
*
|
|
* Use an absolute path to override the base path of the client, or a
|
|
* relative path to append to the base path of the client. The URL can
|
|
* contain the query string as well.
|
|
*
|
|
* @param string $method HTTP method.
|
|
* @param string|UriInterface $uri URI object or string.
|
|
* @param array{
|
|
* base_uri?: string|UriInterface,
|
|
* allow_redirects?: bool|array{
|
|
* max?: int,
|
|
* strict?: bool,
|
|
* referer?: bool,
|
|
* protocols?: non-empty-array<array-key, string>,
|
|
* on_redirect?: callable(RequestInterface, ResponseInterface, UriInterface): mixed,
|
|
* track_redirects?: bool
|
|
* },
|
|
* auth?: array{
|
|
* 0: string,
|
|
* 1: string,
|
|
* 2?: string|null
|
|
* }|string|false|null,
|
|
* body?: resource|string|null|StreamInterface|(callable&object)|\Iterator|\Stringable,
|
|
* cert?: string|array{
|
|
* 0: string,
|
|
* 1?: string|null
|
|
* },
|
|
* cert_type?: string,
|
|
* connect_timeout?: int|float,
|
|
* cookies?: false|CookieJarInterface,
|
|
* crypto_method?: int,
|
|
* crypto_method_max?: int,
|
|
* debug?: bool|resource,
|
|
* decode_content?: bool|string,
|
|
* delay?: int|float,
|
|
* expect?: bool|int,
|
|
* form_params?: array<array-key, string|int|float|bool|null|array>,
|
|
* force_ip_resolve?: string,
|
|
* headers?: array<array-key, string|non-empty-array<array-key, string>>|null,
|
|
* http_errors?: bool,
|
|
* idn_conversion?: bool|int|null,
|
|
* json?: mixed,
|
|
* multipart?: array<array-key, array{
|
|
* name: string|int,
|
|
* contents: mixed,
|
|
* headers?: array<array-key, string>,
|
|
* filename?: string
|
|
* }>,
|
|
* multiplex?: string,
|
|
* on_headers?: callable(ResponseInterface, RequestInterface): mixed,
|
|
* on_stats?: callable(TransferStats): mixed,
|
|
* on_trailers?: callable(array<string, list<string>>, ResponseInterface, RequestInterface): mixed,
|
|
* progress?: callable(int, int, int, int): mixed,
|
|
* protocols?: non-empty-array<array-key, string>,
|
|
* proxy?: string|array{
|
|
* http?: string|null,
|
|
* https?: string|null,
|
|
* no?: string|array<array-key, string>|null
|
|
* },
|
|
* query?: array<array-key, mixed>|string,
|
|
* read_timeout?: int|float,
|
|
* retries?: int,
|
|
* request_factory?: RequestFactoryInterface,
|
|
* response_factory?: ResponseFactoryInterface,
|
|
* sink?: resource|string|StreamInterface,
|
|
* ssl_key?: string|array{
|
|
* 0: string,
|
|
* 1?: string|null
|
|
* },
|
|
* ssl_key_type?: string,
|
|
* stream?: bool,
|
|
* stream_factory?: StreamFactoryInterface,
|
|
* stream_context?: array<array-key, mixed>,
|
|
* synchronous?: bool,
|
|
* timeout?: int|float,
|
|
* uri_factory?: UriFactoryInterface,
|
|
* verify?: bool|string,
|
|
* version?: string|int|float,
|
|
* curl?: array<int|string, mixed>,
|
|
* ...
|
|
* } $options Request options to apply.
|
|
*
|
|
* @throws GuzzleException
|
|
*/
|
|
public function request(string $method, $uri, array $options = []): ResponseInterface;
|
|
|
|
/**
|
|
* Create and send an asynchronous HTTP request.
|
|
*
|
|
* Use an absolute path to override the base path of the client, or a
|
|
* relative path to append to the base path of the client. The URL can
|
|
* contain the query string as well.
|
|
*
|
|
* @param string $method HTTP method
|
|
* @param string|UriInterface $uri URI object or string.
|
|
* @param array{
|
|
* base_uri?: string|UriInterface,
|
|
* allow_redirects?: bool|array{
|
|
* max?: int,
|
|
* strict?: bool,
|
|
* referer?: bool,
|
|
* protocols?: non-empty-array<array-key, string>,
|
|
* on_redirect?: callable(RequestInterface, ResponseInterface, UriInterface): mixed,
|
|
* track_redirects?: bool
|
|
* },
|
|
* auth?: array{
|
|
* 0: string,
|
|
* 1: string,
|
|
* 2?: string|null
|
|
* }|string|false|null,
|
|
* body?: resource|string|null|StreamInterface|(callable&object)|\Iterator|\Stringable,
|
|
* cert?: string|array{
|
|
* 0: string,
|
|
* 1?: string|null
|
|
* },
|
|
* cert_type?: string,
|
|
* connect_timeout?: int|float,
|
|
* cookies?: false|CookieJarInterface,
|
|
* crypto_method?: int,
|
|
* crypto_method_max?: int,
|
|
* debug?: bool|resource,
|
|
* decode_content?: bool|string,
|
|
* delay?: int|float,
|
|
* expect?: bool|int,
|
|
* form_params?: array<array-key, string|int|float|bool|null|array>,
|
|
* force_ip_resolve?: string,
|
|
* headers?: array<array-key, string|non-empty-array<array-key, string>>|null,
|
|
* http_errors?: bool,
|
|
* idn_conversion?: bool|int|null,
|
|
* json?: mixed,
|
|
* multipart?: array<array-key, array{
|
|
* name: string|int,
|
|
* contents: mixed,
|
|
* headers?: array<array-key, string>,
|
|
* filename?: string
|
|
* }>,
|
|
* multiplex?: string,
|
|
* on_headers?: callable(ResponseInterface, RequestInterface): mixed,
|
|
* on_stats?: callable(TransferStats): mixed,
|
|
* on_trailers?: callable(array<string, list<string>>, ResponseInterface, RequestInterface): mixed,
|
|
* progress?: callable(int, int, int, int): mixed,
|
|
* protocols?: non-empty-array<array-key, string>,
|
|
* proxy?: string|array{
|
|
* http?: string|null,
|
|
* https?: string|null,
|
|
* no?: string|array<array-key, string>|null
|
|
* },
|
|
* query?: array<array-key, mixed>|string,
|
|
* read_timeout?: int|float,
|
|
* retries?: int,
|
|
* request_factory?: RequestFactoryInterface,
|
|
* response_factory?: ResponseFactoryInterface,
|
|
* sink?: resource|string|StreamInterface,
|
|
* ssl_key?: string|array{
|
|
* 0: string,
|
|
* 1?: string|null
|
|
* },
|
|
* ssl_key_type?: string,
|
|
* stream?: bool,
|
|
* stream_factory?: StreamFactoryInterface,
|
|
* stream_context?: array<array-key, mixed>,
|
|
* synchronous?: bool,
|
|
* timeout?: int|float,
|
|
* uri_factory?: UriFactoryInterface,
|
|
* verify?: bool|string,
|
|
* version?: string|int|float,
|
|
* curl?: array<int|string, mixed>,
|
|
* ...
|
|
* } $options Request options to apply.
|
|
*
|
|
* @return PromiseInterface<ResponseInterface, mixed>
|
|
*/
|
|
public function requestAsync(string $method, $uri, array $options = []): PromiseInterface;
|
|
}
|