CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
      • Client
        • Adapter
        • Auth
        • Exception
      • Cookie
      • Exception
      • Link
      • Middleware
      • RateLimit
      • Response
      • Session
      • TestSuite
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class Stream

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

This approach and implementation is partly inspired by Aura.Http

Namespace: Cake\Http\Client\Adapter

Property Summary

  • $connectionErrors protected
    list<string>

    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.

  • $sslContextOptions protected
    array<string, mixed>

    Array of options/content for the SSL stream context.

  • $stream protected
    resource|null

    The stream resource.

Method Summary

  • buildContent() protected

    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}

  • buildContext() protected

    Build the stream context out of the request object.

  • buildHeaders() protected

    Build the header context for the request.

    Creates cookies & headers.

  • buildOptions() protected

    Build miscellaneous options for the request.

  • buildResponse() protected

    Build a response object

  • buildSslContext() protected

    Build SSL options for the request.

  • contextOptions() public

    Get the context options

    Useful for debugging and testing context creation.

  • createResponses() public

    Create the response list based on the headers & content

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

  • open() protected

    Open the socket and handle any connection errors.

  • processRequest() protected

    Open the stream and send the request.

  • processStreamingRequest() protected

    Return after headers arrive, transferring ownership of the connection to the body.

  • send() public

    Send a request and get a response back.

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(list<string> $headers, Psr\Http\Message\StreamInterface|string $body): Cake\Http\Client\Response

Build a response object

Parameters
list<string> $headers

Unparsed headers.

Psr\Http\Message\StreamInterface|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

contextOptions() ¶ public

contextOptions(): array<string, mixed>

Get the context options

Useful for debugging and testing context creation.

Returns
array<string, mixed>

createResponses() ¶ public

createResponses(list<string> $headers, Psr\Http\Message\StreamInterface|string $content): non-empty-list<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
list<string> $headers

The list of headers from the request(s)

Psr\Http\Message\StreamInterface|string $content

The response content.

Returns
non-empty-list<Cake\Http\Client\Response>

The list of responses from the request(s)

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

processRequest() ¶ protected

processRequest(Psr\Http\Message\RequestInterface $request): non-empty-list<Cake\Http\Client\Response>

Open the stream and send the request.

Parameters
Psr\Http\Message\RequestInterface $request

The request object.

Returns
non-empty-list<Cake\Http\Client\Response>

Array of populated Response objects

Throws
Psr\Http\Client\NetworkExceptionInterface

processStreamingRequest() ¶ protected

processStreamingRequest(Psr\Http\Message\RequestInterface $request, array<string, mixed> $options): non-empty-list<Cake\Http\Client\Response>

Return after headers arrive, transferring ownership of the connection to the body.

Parameters
Psr\Http\Message\RequestInterface $request

The request object.

array<string, mixed> $options

Request options.

Returns
non-empty-list<Cake\Http\Client\Response>

send() ¶ public

send(Psr\Http\Message\RequestInterface $request, array<string, mixed> $options): non-empty-list<Cake\Http\Client\Response>

Send a request and get a response back.

Parameters
Psr\Http\Message\RequestInterface $request
array<string, mixed> $options
Returns
non-empty-list<Cake\Http\Client\Response>

Property Detail

$connectionErrors ¶ protected

Connection error list.

Type
list<string>

$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
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs