Class Stream
Implements sending Cake\Http\Client\Request via php's stream API.
This approach and implementation is partly inspired by Aura.Http
- Cake\Http\Client\Adapter\Stream implements Cake\Http\Client\AdapterInterface
Properties summary
-
$_connectionErrors
protectedarray
-
$_context
protectedresource|null
-
$_contextOptions
protectedarray
-
$_sslContextOptions
protectedarray
-
$_stream
protectedresource|null
Method Summary
-
_buildContent() protectedBuilds the request content based on the request object.
-
_buildContext() protectedBuild the stream context out of the request object.
-
_buildHeaders() protectedBuild the header context for the request.
-
_buildOptions() protectedBuild miscellaneous options for the request.
-
_buildResponse() protectedBuild a response object
-
_buildSslContext() protectedBuild SSL options for the request.
-
_open() protectedOpen the socket and handle any connection errors.
-
_send() protectedOpen the stream and send the request.
-
contextOptions() publicGet the context options
-
createResponses() publicCreate the response list based on the headers & content
-
send() publicSend a request and get a response back.
Method Detail
_buildContent()source protected
_buildContent( Cake\Http\Client\Request $request , array $options )
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.
_buildContext()source protected
_buildContext( Cake\Http\Client\Request $request , array $options )
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()source protected
_buildHeaders( Cake\Http\Client\Request $request , array $options )
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.
_buildOptions()source protected
_buildOptions( Cake\Http\Client\Request $request , array $options )
Build miscellaneous options for the request.
Parameters
-
Cake\Http\Client\Request
$request
- The request being sent.
-
array
$options
- Array of options to use.
_buildResponse()source protected
_buildResponse( array $headers , string $body )
Build a response object
Parameters
-
array
$headers
- Unparsed headers.
-
string
$body
- The response body.
Returns
Cake\Http\Client\Response
_buildSslContext()source protected
_buildSslContext( Cake\Http\Client\Request $request , array $options )
Build SSL options for the request.
Parameters
-
Cake\Http\Client\Request
$request
- The request being sent.
-
array
$options
- Array of options to use.
_open()source protected
_open( string $url )
Open the socket and handle any connection errors.
Parameters
-
string
$url
- The url to connect to.
Throws
Cake\Core\Exception\Exception
_send()source protected
_send( Cake\Http\Client\Request $request )
Open the stream and send the request.
Parameters
-
Cake\Http\Client\Request
$request
- The request object.
Returns
arrayArray of populated Response objects
Throws
Cake\Http\Exception\HttpException
contextOptions()source public
contextOptions( )
Get the context options
Useful for debugging and testing context creation.
Returns
arraycreateResponses()source public
createResponses( array $headers , string $content )
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
Cake\Http\Client\Response[]
The list of responses from the request(s)
send()source public
send( Cake\Http\Client\Request $request , array $options )
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
Cake\Http\Client\Response[]
Array of populated Response objects
Implementation of
Cake\Http\Client\AdapterInterface::send()
Properties detail
© 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/3.8/class-Cake.Http.Client.Adapter.Stream.html