\Guzzle\StreamPhpStreamRequestFactory

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.

Summary

Methods
Properties
Constants
fromRequest()
getLastResponseHeaders()
No public properties found
No constants found
setContextValue()
createContext()
addDefaultContextOptions()
setUrl()
addSslOptions()
addBodyOptions()
addProxyOptions()
createStream()
processResponseHeaders()
createResource()
$context
$contextOptions
$url
$lastResponseHeaders
N/A
No private methods found
No private properties found
N/A

Properties

$context

$context : resource

Type

resource — Stream context options

$contextOptions

$contextOptions : array

Type

array — Stream context

$lastResponseHeaders

$lastResponseHeaders : array

Type

array — Last response headers received by the HTTP request

Methods

fromRequest()

fromRequest(\Guzzle\Http\Message\RequestInterface  $request, array|resource  $context = array(), array  $params = array()) : \Guzzle\Stream\StreamInterface

Create a stream based on a request object

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

\Guzzle\Http\Message\RequestInterface $request

Base the stream on a request

array|resource $context

A stream_context_options resource or array of parameters used to create a stream context.

array $params

Optional array of parameters specific to the factory

Returns

\Guzzle\Stream\StreamInterface

Returns a stream object

getLastResponseHeaders()

getLastResponseHeaders() : array

Get the last response headers received by the HTTP request

Returns

array

setContextValue()

setContextValue(string  $wrapper, string  $name, mixed  $value, boolean  $overwrite = false) 

Set an option on the context and the internal options array

Parameters

string $wrapper

Stream wrapper name of http

string $name

Context name

mixed $value

Context value

boolean $overwrite

Set to true to overwrite an existing value

createContext()

createContext(array  $params) 

Create a stream context

Parameters

array $params

Parameter array

addDefaultContextOptions()

addDefaultContextOptions(\Guzzle\Http\Message\RequestInterface  $request) 

Adds the default context options to the stream context options

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request

setUrl()

setUrl(\Guzzle\Http\Message\RequestInterface  $request) 

Set the URL to use with the factory

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request that owns the URL

addBodyOptions()

addBodyOptions(\Guzzle\Http\Message\RequestInterface  $request) 

Add body (content) specific options to the context options

Parameters

\Guzzle\Http\Message\RequestInterface $request

addProxyOptions()

addProxyOptions(\Guzzle\Http\Message\RequestInterface  $request) 

Add proxy parameters to the context if needed

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request

createStream()

createStream(array  $params) : \Guzzle\Stream\StreamInterface

Create the stream for the request with the context options

Parameters

array $params

Parameters of the stream

Returns

\Guzzle\Stream\StreamInterface

processResponseHeaders()

processResponseHeaders(\Guzzle\Stream\StreamInterface  $stream) 

Process response headers

Parameters

\Guzzle\Stream\StreamInterface $stream

createResource()

createResource(callable  $callback) : resource

Create a resource and check to ensure it was created successfully

Parameters

callable $callback

Closure to invoke that must return a valid resource

Throws

\Guzzle\Common\Exception\RuntimeException

on error

Returns

resource