Documentation

StreamHandler
in package

HTTP handler that uses PHP's HTTP stream wrapper.

Tags
final

Table of Contents

Constants

CONNECTION_ERRORS  : mixed = [ 'php_network_getaddresses:', 'getaddrinfo', '...
KNOWN_CONSTRUCTOR_OPTIONS  : mixed = ['max_host_connections' => true, 'max_total_con...

Properties

$connectionCapsConfigured  : bool
$lastHeaders  : array<string|int, mixed>
$transportSharingMode  : string

Methods

__construct()  : mixed
Accepts an associative array of options:
__invoke()  : PromiseInterface
Sends an HTTP request.
add_cert()  : void
add_cert_type()  : void
add_crypto_method()  : void
add_crypto_method_max()  : void
add_debug()  : void
add_progress()  : void
add_proxy()  : bool
add_ssl_key()  : void
add_ssl_key_type()  : void
add_timeout()  : void
add_verify()  : void
addNotification()  : void
assertStreamTlsType()  : void
assertTlsVersionRangeForOptions()  : void
assertTransportSharingSupported()  : void
callArray()  : callable
canonicalConnectionHost()  : string
Returns a numeric IPv4 spelling folded to the dotted quad libcurl's ipv4_normalize() produces, and every other host unchanged.
checkDecode()  : array<string|int, mixed>
conflictingStreamContextOptions()  : array<string, array<string, string>>
createResource()  : resource
Create a resource and check to ensure it was created successfully
createResponse()  : PromiseInterface
createSink()  : StreamInterface
createStream()  : resource
drain()  : StreamInterface
Drains the source stream into the "sink" client option.
getDefaultContext()  : array<string|int, mixed>
invokeStats()  : void
isConnectionError()  : bool
isCurlOptionGeneratedByAuth()  : bool
normalizeTlsFileOption()  : array{0: string, 1: string|null}
numericIpv4PartValue()  : float
Returns the value of one accepted part as a float, so a part filling all four octets such as 2130706433 stays exact on every integer width.
numericIpv4ToBinary()  : string|null
Returns the four-byte binary form of a host that a transport reads as a numeric IPv4 address, or null when it reads it as a name.
parse_proxy()  : array<string|int, mixed>
Parses the given proxy URL to make it compatible with the format PHP's stream context expects.
rejectResponseCreation()  : PromiseInterface
resolveHost()  : UriInterface
setTlsPassphrase()  : void
supportedStreamContextOptions()  : array<string, array<string, true>>
triggerConflictingStreamContextOptionDeprecations()  : void
triggerUnsupportedRequestOptionDeprecations()  : void
triggerUnsupportedStreamContextOptionDeprecations()  : void
unsupportedStreamContextOptions()  : array<string|int, string>

Constants

CONNECTION_ERRORS

private mixed CONNECTION_ERRORS = [ 'php_network_getaddresses:', 'getaddrinfo', 'gethostbyname failed', 'Connection refused', 'No connection could be made because the target machine actively refused it', "couldn't connect to host", // error on HHVM 'connection attempt failed', 'connect() failed', 'Connection timed out', 'Operation timed out', 'Network is unreachable', 'No route to host', 'Host is unreachable', 'Host is down', 'Cannot connect to HTTPS server through proxy', ]

KNOWN_CONSTRUCTOR_OPTIONS

private mixed KNOWN_CONSTRUCTOR_OPTIONS = ['max_host_connections' => true, 'max_total_connections' => true, 'transport_sharing' => true]

Properties

$connectionCapsConfigured

private bool $connectionCapsConfigured = false

$lastHeaders

private array<string|int, mixed> $lastHeaders = []

Methods

__construct()

Accepts an associative array of options:

public __construct([array{max_host_connections?: mixed, max_total_connections?: mixed, transport_sharing?: mixed} $options = [] ]) : mixed
  • max_host_connections: Optional positive integer or null. A non-null value marks the handler as incompatible with enabled response streaming; the number is not used for stream-handler admission.
  • max_total_connections: Optional positive integer or null. A non-null value marks the handler as incompatible with enabled response streaming; the number is not used for stream-handler admission.
  • transport_sharing: Optional transport sharing mode.

The stream handler cannot cap streamed connections, so a configured cap marker rejects enabled response streaming ("stream" => true). Accepted transfers are buffered and hold at most one connection per in-flight call, but overlapping buffered calls are not collectively limited.

Parameters
$options : array{max_host_connections?: mixed, max_total_connections?: mixed, transport_sharing?: mixed} = []

Array of options to use with the handler

add_cert()

private add_cert(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_cert_type()

private add_cert_type(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_crypto_method()

private add_crypto_method(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_crypto_method_max()

private add_crypto_method_max(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_debug()

private add_debug(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_progress()

private add_progress(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_proxy()

private add_proxy(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : bool
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>
Return values
bool

add_ssl_key()

private add_ssl_key(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_ssl_key_type()

private add_ssl_key_type(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_timeout()

private add_timeout(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

add_verify()

private add_verify(RequestInterface $request, array<string|int, mixed> &$options, mixed $value, array<string|int, mixed> &$params) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>
$value : mixed

as passed via Request transfer options.

$params : array<string|int, mixed>

addNotification()

private static addNotification(array<string|int, mixed> &$params, callable $notify) : void
Parameters
$params : array<string|int, mixed>
$notify : callable

assertStreamTlsType()

private static assertStreamTlsType(string $option, mixed $value) : void
Parameters
$option : string
$value : mixed

as passed via Request transfer options.

assertTlsVersionRangeForOptions()

private static assertTlsVersionRangeForOptions(array<string|int, mixed> $options) : void
Parameters
$options : array<string|int, mixed>

assertTransportSharingSupported()

private assertTransportSharingSupported() : void

callArray()

private static callArray(array<string|int, mixed> $functions) : callable
Parameters
$functions : array<string|int, mixed>
Return values
callable

canonicalConnectionHost()

Returns a numeric IPv4 spelling folded to the dotted quad libcurl's ipv4_normalize() produces, and every other host unchanged.

private static canonicalConnectionHost(string $host) : string
Parameters
$host : string
Return values
string

checkDecode()

private checkDecode(array<string|int, mixed> $options, array<string|int, mixed> $headers, resource $stream) : array<string|int, mixed>
Parameters
$options : array<string|int, mixed>
$headers : array<string|int, mixed>
$stream : resource
Return values
array<string|int, mixed>

conflictingStreamContextOptions()

private static conflictingStreamContextOptions() : array<string, array<string, string>>
Return values
array<string, array<string, string>>

createResource()

Create a resource and check to ensure it was created successfully

private createResource(callable $callback) : resource
Parameters
$callback : callable

Callable that returns stream resource

Tags
throws
RuntimeException

on error

Return values
resource

isConnectionError()

private static isConnectionError(string $message) : bool
Parameters
$message : string
Return values
bool

isCurlOptionGeneratedByAuth()

private static isCurlOptionGeneratedByAuth(array<string|int, mixed> $options) : bool
Parameters
$options : array<string|int, mixed>
Return values
bool

normalizeTlsFileOption()

private static normalizeTlsFileOption(string $option, mixed $value) : array{0: string, 1: string|null}
Parameters
$option : string
$value : mixed

as passed via Request transfer options.

Return values
array{0: string, 1: string|null}

numericIpv4PartValue()

Returns the value of one accepted part as a float, so a part filling all four octets such as 2130706433 stays exact on every integer width.

private static numericIpv4PartValue(string $part) : float
Parameters
$part : string
Return values
float

numericIpv4ToBinary()

Returns the four-byte binary form of a host that a transport reads as a numeric IPv4 address, or null when it reads it as a name.

private static numericIpv4ToBinary(string $host) : string|null

The shape test is HostValidator::isNumericIpv4Host(); this method adds the range checks that predicate omits: every part but the last must fit one octet, and the last must fit the octets the earlier parts left. A trailing root dot is not swallowed, unlike libcurl 8.21.0 and later, because assertRequestHost() rejects that spelling first.

Parameters
$host : string
Return values
string|null

parse_proxy()

Parses the given proxy URL to make it compatible with the format PHP's stream context expects.

private parse_proxy(string $url) : array<string|int, mixed>
Parameters
$url : string
Return values
array<string|int, mixed>

setTlsPassphrase()

private static setTlsPassphrase(array<string|int, mixed> &$options, string|null $passphrase, string $option) : void
Parameters
$options : array<string|int, mixed>
$passphrase : string|null
$option : string

supportedStreamContextOptions()

private static supportedStreamContextOptions() : array<string, array<string, true>>
Return values
array<string, array<string, true>>

triggerConflictingStreamContextOptionDeprecations()

private static triggerConflictingStreamContextOptionDeprecations(array<string|int, mixed> $streamContext) : void
Parameters
$streamContext : array<string|int, mixed>

triggerUnsupportedRequestOptionDeprecations()

private static triggerUnsupportedRequestOptionDeprecations(RequestInterface $request, array<string|int, mixed> $options) : void
Parameters
$request : RequestInterface
$options : array<string|int, mixed>

triggerUnsupportedStreamContextOptionDeprecations()

private static triggerUnsupportedStreamContextOptionDeprecations(array<string|int, mixed> $streamContext) : void
Parameters
$streamContext : array<string|int, mixed>

unsupportedStreamContextOptions()

private static unsupportedStreamContextOptions(array<string|int, mixed> $streamContext) : array<string|int, string>
Parameters
$streamContext : array<string|int, mixed>
Return values
array<string|int, string>
On this page

Search results