W3cubDocs

/CakePHP 4.4

Class Stream

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

This approach and implementation is partly inspired by Aura.Http

Property Summary

  • $_connectionErrors protected
    array

    Connection error list.

  • $_context protected
    resource|null

    Context resource used by the stream API.

  • $_contextOptions protected
    array<string, mixed>

    Array of options/content for the HTTP stream context.

  • array<string, mixed>

    Array of options/content for the SSL stream context.

  • $_stream protected
    resource|null

    The stream resource.

Method Summary

Method Detail

_buildContent() protected

_buildContent(Psr\Http\Message\RequestInterface $request, array<string, mixed> $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 {@link \Cake\Http\Client\FormData}

Parameters

Psr\Http\Message\RequestInterface $request

The request being sent.

array<string, mixed> $options

Array of options to use.

Returns

void

_buildContext() protected

_buildContext(Psr\Http\Message\RequestInterface $request, array<string, mixed> $options): void

Build the stream context out of the request object.

Parameters

Psr\Http\Message\RequestInterface $request

The request to build context from.

array<string, mixed> $options

Additional request options.

Returns

void

_buildHeaders() protected

_buildHeaders(Psr\Http\Message\RequestInterface $request, array<string, mixed> $options): void

Build the header context for the request.

Creates cookies & headers.

Parameters

Psr\Http\Message\RequestInterface $request

The request being sent.

array<string, mixed> $options

Array of options to use.

Returns

void

_buildOptions() protected

_buildOptions(Psr\Http\Message\RequestInterface $request, array<string, mixed> $options): void

Build miscellaneous options for the request.

Parameters

Psr\Http\Message\RequestInterface $request

The request being sent.

array<string, mixed> $options

Array of options to use.

Returns

void

_buildResponse() protected

_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

_buildSslContext() protected

_buildSslContext(Psr\Http\Message\RequestInterface $request, array<string, mixed> $options): void

Build SSL options for the request.

Parameters

Psr\Http\Message\RequestInterface $request

The request being sent.

array<string, mixed> $options

Array of options to use.

Returns

void

_open() protected

_open(string $url, Psr\Http\Message\RequestInterface $request): void

Open the socket and handle any connection errors.

Parameters

string $url

The url to connect to.

Psr\Http\Message\RequestInterface $request

The request object.

Returns

void

Throws

Psr\Http\Client\RequestExceptionInterface

_send() protected

_send(Psr\Http\Message\RequestInterface $request): array

Open the stream and send the request.

Parameters

Psr\Http\Message\RequestInterface $request

The request object.

Returns

array

Throws

Psr\Http\Client\NetworkExceptionInterface

contextOptions() public

contextOptions(): array<string, mixed>

Get the context options

Useful for debugging and testing context creation.

Returns

array<string, mixed>

createResponses() public

createResponses(array $headers, string $content): arrayCake\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

arrayCake\Http\Client\Response>

send() public

send(Psr\Http\Message\RequestInterface $request, array<string, mixed> $options): arrayCake\Http\Client\Response>

Send a request and get a response back.

Parameters

Psr\Http\Message\RequestInterface $request
array<string, mixed> $options

Returns

arrayCake\Http\Client\Response>

Property Detail

$_connectionErrors protected

Connection error list.

Type

array

$_context protected

Context resource used by the stream API.

Type

resource|null

$_contextOptions protected

Array of options/content for the HTTP stream context.

Type

array<string, mixed>

$_sslContextOptions protected

Array of options/content for the SSL stream context.

Type

array<string, mixed>

$_stream protected

The stream resource.

Type

resource|null

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Http.Client.Adapter.Stream.html