\Cake\Http\Client\AdapterStream

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

This approach and implementation is partly inspired by Aura.Http

Summary

Methods
Properties
Constants
send()
createResponses()
contextOptions()
No public properties found
No constants found
_buildContext()
_buildHeaders()
_buildContent()
_buildOptions()
_buildSslContext()
_send()
_buildResponse()
_open()
$_context
$_contextOptions
$_sslContextOptions
$_stream
$_connectionErrors
N/A
No private methods found
No private properties found
N/A

Properties

$_context

$_context : resource|null

Context resource used by the stream API.

Type

resource|null

$_contextOptions

$_contextOptions : array

Array of options/content for the HTTP stream context.

Type

array

$_sslContextOptions

$_sslContextOptions : array

Array of options/content for the SSL stream context.

Type

array

$_stream

$_stream : resource|null

The stream resource.

Type

resource|null

$_connectionErrors

$_connectionErrors : array

Connection error list.

Type

array

Methods

send()

send(\Cake\Http\Client\Request  $request, array  $options) : array<mixed,\Cake\Http\Client\Response>

Send a request and get a response back.

Parameters

\Cake\Http\Client\Request $request

The request object to send.

array $options

Array of options for the stream.

Returns

array<mixed,\Cake\Http\Client\Response> —

Array of populated Response objects

createResponses()

createResponses(array  $headers, string  $content) : array<mixed,\Cake\Http\Client\Response>

Create the response list based on the headers & content

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

Parameters

array $headers

The list of headers from the request(s)

string $content

The response content.

Returns

array<mixed,\Cake\Http\Client\Response> —

The list of responses from the request(s)

contextOptions()

contextOptions() : array

Get the context options

Useful for debugging and testing context creation.

Returns

array

_buildContext()

_buildContext(\Cake\Http\Client\Request  $request, array  $options) : void

Build the stream context out of the request object.

Parameters

\Cake\Http\Client\Request $request

The request to build context from.

array $options

Additional request options.

_buildHeaders()

_buildHeaders(\Cake\Http\Client\Request  $request, array  $options) : void

Build the header context for the request.

Creates cookies & headers.

Parameters

\Cake\Http\Client\Request $request

The request being sent.

array $options

Array of options to use.

_buildContent()

_buildContent(\Cake\Http\Client\Request  $request, array  $options) : void

Builds the request content based on the request object.

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

Parameters

\Cake\Http\Client\Request $request

The request being sent.

array $options

Array of options to use.

_buildOptions()

_buildOptions(\Cake\Http\Client\Request  $request, array  $options) : void

Build miscellaneous options for the request.

Parameters

\Cake\Http\Client\Request $request

The request being sent.

array $options

Array of options to use.

_buildSslContext()

_buildSslContext(\Cake\Http\Client\Request  $request, array  $options) : void

Build SSL options for the request.

Parameters

\Cake\Http\Client\Request $request

The request being sent.

array $options

Array of options to use.

_send()

_send(\Cake\Http\Client\Request  $request) : array

Open the stream and send the request.

Parameters

\Cake\Http\Client\Request $request

The request object.

Throws

\Cake\Http\Exception\HttpException

Returns

array —

Array of populated Response objects

_buildResponse()

_buildResponse(array  $headers, string  $body) : \Cake\Http\Client\Response

Build a response object

Parameters

array $headers

Unparsed headers.

string $body

The response body.

Returns

\Cake\Http\Client\Response

_open()

_open(string  $url) : void

Open the socket and handle any connection errors.

Parameters

string $url

The url to connect to.

Throws

\Cake\Core\Exception\Exception