Fr3nch13/CakePHP Utilities

Stream
in package
implements AdapterInterface

Implements sending Cake\Http\Client\Request via php's stream API.

This approach and implementation is partly inspired by Aura.Http

Table of Contents

Interfaces

AdapterInterface
Http client adapter interface.

Properties

$_connectionErrors  : array<string|int, mixed>
Connection error list.
$_context  : resource|null
Context resource used by the stream API.
$_contextOptions  : array<string, mixed>
Array of options/content for the HTTP stream context.
$_sslContextOptions  : array<string, mixed>
Array of options/content for the SSL stream context.
$_stream  : resource|null
The stream resource.

Methods

contextOptions()  : array<string, mixed>
Get the context options
createResponses()  : array<string|int, Response>
Create the response list based on the headers & content
send()  : array<string|int, Response>
Send a request and get a response back.
_buildContent()  : void
Builds the request content based on the request object.
_buildContext()  : void
Build the stream context out of the request object.
_buildHeaders()  : void
Build the header context for the request.
_buildOptions()  : void
Build miscellaneous options for the request.
_buildResponse()  : Response
Build a response object
_buildSslContext()  : void
Build SSL options for the request.
_open()  : void
Open the socket and handle any connection errors.
_send()  : array<string|int, mixed>
Open the stream and send the request.

Properties

$_connectionErrors

Connection error list.

protected array<string|int, mixed> $_connectionErrors = []

$_context

Context resource used by the stream API.

protected resource|null $_context

$_contextOptions

Array of options/content for the HTTP stream context.

protected array<string, mixed> $_contextOptions = []

$_sslContextOptions

Array of options/content for the SSL stream context.

protected array<string, mixed> $_sslContextOptions = []

$_stream

The stream resource.

protected resource|null $_stream

Methods

contextOptions()

Get the context options

public contextOptions() : array<string, mixed>

Useful for debugging and testing context creation.

Return values
array<string, mixed>

createResponses()

Create the response list based on the headers & content

public createResponses(array<string|int, mixed> $headers, string $content) : array<string|int, Response>

Creates one or many response objects based on the number of redirects that occurred.

Parameters
$headers : array<string|int, mixed>

The list of headers from the request(s)

$content : string

The response content.

Return values
array<string|int, Response>

The list of responses from the request(s)

send()

Send a request and get a response back.

public send(RequestInterface $request, array<string|int, mixed> $options) : array<string|int, Response>
Parameters
$request : RequestInterface

The request object to send.

$options : array<string|int, mixed>

Array of options for the stream.

Tags
inheritDoc
Return values
array<string|int, Response>

Array of populated Response objects

_buildContent()

Builds the request content based on the request object.

protected _buildContent(RequestInterface $request, array<string, mixed> $options) : void

If the $request->body() is a string, it will be used as is. Array data will be processed with

Parameters
$request : RequestInterface

The request being sent.

$options : array<string, mixed>

Array of options to use.

_buildContext()

Build the stream context out of the request object.

protected _buildContext(RequestInterface $request, array<string, mixed> $options) : void
Parameters
$request : RequestInterface

The request to build context from.

$options : array<string, mixed>

Additional request options.

_buildHeaders()

Build the header context for the request.

protected _buildHeaders(RequestInterface $request, array<string, mixed> $options) : void

Creates cookies & headers.

Parameters
$request : RequestInterface

The request being sent.

$options : array<string, mixed>

Array of options to use.

_buildOptions()

Build miscellaneous options for the request.

protected _buildOptions(RequestInterface $request, array<string, mixed> $options) : void
Parameters
$request : RequestInterface

The request being sent.

$options : array<string, mixed>

Array of options to use.

_buildResponse()

Build a response object

protected _buildResponse(array<string|int, mixed> $headers, string $body) : Response
Parameters
$headers : array<string|int, mixed>

Unparsed headers.

$body : string

The response body.

Return values
Response

_buildSslContext()

Build SSL options for the request.

protected _buildSslContext(RequestInterface $request, array<string, mixed> $options) : void
Parameters
$request : RequestInterface

The request being sent.

$options : array<string, mixed>

Array of options to use.


        
On this page

Search results