PhpStreamRequestFactory
in package
implements
StreamRequestFactoryInterface
Factory used to create fopen streams using PHP's http and https stream wrappers
Note: PHP's http stream wrapper only supports streaming downloads. It does not support streaming uploads.
Table of Contents
Interfaces
- StreamRequestFactoryInterface
- Interface used for creating streams from requests
Properties
- $context : resource
- $contextOptions : array<string|int, mixed>
- $lastResponseHeaders : array<string|int, mixed>
- $url : Url
Methods
- fromRequest() : StreamInterface
- Create a stream based on a request object
- getLastResponseHeaders() : array<string|int, mixed>
- Get the last response headers received by the HTTP request
- addBodyOptions() : mixed
- Add body (content) specific options to the context options
- addDefaultContextOptions() : mixed
- Adds the default context options to the stream context options
- addProxyOptions() : mixed
- Add proxy parameters to the context if needed
- addSslOptions() : mixed
- Add SSL options to the stream context
- createContext() : mixed
- Create a stream context
- createResource() : resource
- Create a resource and check to ensure it was created successfully
- createStream() : StreamInterface
- Create the stream for the request with the context options
- processResponseHeaders() : mixed
- Process response headers
- setContextValue() : mixed
- Set an option on the context and the internal options array
- setUrl() : mixed
- Set the URL to use with the factory
Properties
$context
protected
resource
$context
Stream context options
$contextOptions
protected
array<string|int, mixed>
$contextOptions
Stream context
$lastResponseHeaders
protected
array<string|int, mixed>
$lastResponseHeaders
Last response headers received by the HTTP request
$url
protected
Url
$url
Stream URL
Methods
fromRequest()
Create a stream based on a request object
public
fromRequest(RequestInterface $request[, mixed $context = array() ][, array<string|int, mixed> $params = array() ]) : StreamInterface
The $params array can contain the following custom keys specific to the PhpStreamRequestFactory:
- stream_class: The name of a class to create instead of a Guzzle\Stream\Stream object
Parameters
- $request : RequestInterface
-
Base the stream on a request
- $context : mixed = array()
-
A stream_context_options resource or array of parameters used to create a stream context.
- $params : array<string|int, mixed> = array()
-
Optional array of parameters specific to the factory
Return values
StreamInterface —Returns a stream object
getLastResponseHeaders()
Get the last response headers received by the HTTP request
public
getLastResponseHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>addBodyOptions()
Add body (content) specific options to the context options
protected
addBodyOptions(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
addDefaultContextOptions()
Adds the default context options to the stream context options
protected
addDefaultContextOptions(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
-
Request
addProxyOptions()
Add proxy parameters to the context if needed
protected
addProxyOptions(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
-
Request
addSslOptions()
Add SSL options to the stream context
protected
addSslOptions(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
-
Request
createContext()
Create a stream context
protected
createContext(array<string|int, mixed> $params) : mixed
Parameters
- $params : array<string|int, mixed>
-
Parameter array
createResource()
Create a resource and check to ensure it was created successfully
protected
createResource(callable $callback) : resource
Parameters
- $callback : callable
-
Closure to invoke that must return a valid resource
Tags
Return values
resourcecreateStream()
Create the stream for the request with the context options
protected
createStream(array<string|int, mixed> $params) : StreamInterface
Parameters
- $params : array<string|int, mixed>
-
Parameters of the stream
Return values
StreamInterfaceprocessResponseHeaders()
Process response headers
protected
processResponseHeaders(StreamInterface $stream) : mixed
Parameters
- $stream : StreamInterface
setContextValue()
Set an option on the context and the internal options array
protected
setContextValue(string $wrapper, string $name, mixed $value[, bool $overwrite = false ]) : mixed
Parameters
- $wrapper : string
-
Stream wrapper name of http
- $name : string
-
Context name
- $value : mixed
-
Context value
- $overwrite : bool = false
-
Set to true to overwrite an existing value
setUrl()
Set the URL to use with the factory
protected
setUrl(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
-
Request that owns the URL