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
arrayConnection error list.
 - 
        $_context protected
resource|nullContext resource used by the stream API.
 - 
        $_contextOptions protected
arrayArray of options/content for the HTTP stream context.
 - 
        $_sslContextOptions protected
arrayArray of options/content for the SSL stream context.
 - 
        $_stream protected
resource|nullThe stream resource.
 
Method Summary
- 
          
_buildContent() protected
Builds the request content based on the request object.
 - 
          
_buildContext() protected
Build the stream context out of the request object.
 - 
          
_buildHeaders() protected
Build the header context for the request.
 - 
          
_buildOptions() protected
Build miscellaneous options for the request.
 - 
          
_buildResponse() protected
Build a response object
 - 
          
_buildSslContext() protected
Build SSL options for the request.
 - 
          
_open() protected
Open the socket and handle any connection errors.
 - 
          
_send() protected
Open the stream and send the request.
 - 
          
contextOptions() public
Get the context options
 - 
          
createResponses() public
Create the response list based on the headers & content
 - 
          
send() public
Send a request and get a response back.
 
Method Detail
_buildContent() ¶ protected
_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.
Returns
void_buildContext() ¶ protected
_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.
Returns
void_buildHeaders() ¶ protected
_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.
Returns
void_buildOptions() ¶ protected
_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.
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(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.
Returns
void_open() ¶ protected
_open(string $url): void
      Open the socket and handle any connection errors.
Parameters
- 
                
string$url The url to connect to.
Returns
voidThrows
Cake\Core\Exception\Exception_send() ¶ protected
_send(Cake\Http\Client\Request $request): array
      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\HttpExceptioncontextOptions() ¶ public
contextOptions(): array
      Get the context options
Useful for debugging and testing context creation.
Returns
arraycreateResponses() ¶ public
createResponses(array $headers, string $content): 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
Cake\Http\Client\Response[]The list of responses from the request(s)
send() ¶ public
send(Cake\Http\Client\Request $request, array $options): Cake\Http\Client\Response[]
      Send a request and get a response back.
Parameters
- 
                
Cake\Http\Client\Request$request - 
                
array$options 
Returns
Cake\Http\Client\Response[]