Documentation

HttplugClient
in package
implements ClientInterface, HttpAsyncClient, RequestFactoryInterface, StreamFactoryInterface, UriFactoryInterface, ResetInterface

FinalYes

An adapter to turn a Symfony HttpClientInterface into an Httplug client.

In comparison to Psr18Client, this client supports asynchronous requests.

Run "composer require php-http/discovery php-http/async-client-implementation:*" to get the required dependencies.

Tags
author

Nicolas Grekas p@tchwork.com

Table of Contents

Interfaces

ClientInterface
HttpAsyncClient
RequestFactoryInterface
StreamFactoryInterface
UriFactoryInterface
ResetInterface
Provides a way to reset an object to its initial state.

Properties

$autoUpgradeHttpVersion  : bool
$client  : HttpClientInterface
$promisePool  : SplObjectStorage<ResponseInterface, Promise}>|null
$responseFactory  : ResponseFactoryInterface
$streamFactory  : StreamFactoryInterface
$waitLoop  : HttplugWaitLoop

Methods

__construct()  : mixed
__destruct()  : mixed
__serialize()  : array<string|int, mixed>
__unserialize()  : void
createRequest()  : RequestInterface
Create a new request.
createStream()  : StreamInterface
Create a new stream from a string.
createStreamFromFile()  : StreamInterface
Create a stream from an existing file.
createStreamFromResource()  : StreamInterface
Create a new stream from an existing resource.
createUri()  : UriInterface
Create a new URI.
reset()  : void
sendAsyncRequest()  : HttplugPromise
sendRequest()  : ResponseInterface
wait()  : int
Resolves pending promises that complete before the timeouts are reached.
withOptions()  : static
sendPsr7Request()  : ResponseInterface

Properties

$autoUpgradeHttpVersion

private bool $autoUpgradeHttpVersion = true

Methods

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>

createStream()

Create a new stream from a string.

public createStream([string $content = '' ]) : StreamInterface

The stream SHOULD be created with a temporary resource.

Parameters
$content : string = ''

String content with which to populate the stream.

Return values
StreamInterface

createStreamFromFile()

Create a stream from an existing file.

public createStreamFromFile(string $filename[, string $mode = 'r' ]) : StreamInterface

The file MUST be opened using the given mode, which may be any mode supported by the fopen function.

The $filename MAY be any string supported by fopen().

Parameters
$filename : string

Filename or stream URI to use as basis of stream.

$mode : string = 'r'

Mode with which to open the underlying filename/stream.

Return values
StreamInterface

createStreamFromResource()

Create a new stream from an existing resource.

public createStreamFromResource(mixed $resource) : StreamInterface

The stream MUST be readable and may be writable.

Parameters
$resource : mixed

PHP resource to use as basis of stream.

Return values
StreamInterface

wait()

Resolves pending promises that complete before the timeouts are reached.

public wait([float|null $maxDuration = null ][, float|null $idleTimeout = null ]) : int

When $maxDuration is null and $idleTimeout is reached, promises are rejected.

Parameters
$maxDuration : float|null = null
$idleTimeout : float|null = null
Return values
int

The number of remaining pending promises

withOptions()

public withOptions(array<string|int, mixed> $options) : static
Parameters
$options : array<string|int, mixed>
Return values
static

        
On this page

Search results