NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class PhpStreamRequestFactory

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.

  Guzzle\Stream\PhpStreamRequestFactory implements Guzzle\Stream\StreamRequestFactoryInterface

Namespace: Guzzle\Stream
Located at Guzzle/Stream/PhpStreamRequestFactory.php

## Methods summary

- `public` `fromRequest ( Guzzle\Http\Message\RequestInterface $request, array|resource $context = array(), array $params = array() )`

  Create a stream based on a request object

- `protected` `setContextValue ( string $wrapper, string $name, mixed $value, bool $overwrite = false )`

  Set an option on the context and the internal options array

- `protected` `createContext ( array $params )`

  Create a stream context

- `public` `getLastResponseHeaders ( )`

  Get the last response headers received by the HTTP request

- `protected` `addDefaultContextOptions ( Guzzle\Http\Message\RequestInterface $request )`

  Adds the default context options to the stream context options

- `protected` `setUrl ( Guzzle\Http\Message\RequestInterface $request )`

  Set the URL to use with the factory

- `protected` `addSslOptions ( Guzzle\Http\Message\RequestInterface $request )`

  Add SSL options to the stream context

- `protected` `addBodyOptions ( Guzzle\Http\Message\RequestInterface $request )`

  Add body (content) specific options to the context options

- `protected` `addProxyOptions ( Guzzle\Http\Message\RequestInterface $request )`

  Add proxy parameters to the context if needed

- `protected` `createStream ( array $params )`

  Create the stream for the request with the context options

- `protected` `processResponseHeaders ( Guzzle\Stream\StreamInterface $stream )`

  Process response headers

- `protected` `createResource ( callable $callback )`

  Create a resource and check to ensure it was created successfully

## Methods detail

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

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

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request Base the stream on a request
$context
  `array|resource`
  $context A stream_context_options resource or array of parameters used to create a stream context.
$params
  `array`
  $params Optional array of parameters specific to the factory

#### Returns

``Guzzle\Stream\StreamInterface``
Returns a stream object

#### Throws

``Guzzle\Common\Exception\RuntimeException``
if the stream cannot be opened or an error occurs

#### Implementation of

`Guzzle\Stream\StreamRequestFactoryInterface::fromRequest()`
# `protected`
`setContextValue( string $wrapper, string $name, mixed $value, boolean $overwrite = false )`

Set an option on the context and the internal options array

#### Parameters

$wrapper
  `string`
  $wrapper Stream wrapper name of http
$name
  `string`
  $name Context name
$value
  `mixed`
  $value Context value
$overwrite
  `boolean`
  $overwrite Set to true to overwrite an existing value

# `protected`
`createContext( array $params )`

Create a stream context

#### Parameters

$params
  `array`
  $params Parameter array

# `public array`
`getLastResponseHeaders( )`

Get the last response headers received by the HTTP request

#### Returns

`array`
# `protected`
`addDefaultContextOptions( `Guzzle\Http\Message\RequestInterface` $request )`

Adds the default context options to the stream context options

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request Request

# `protected`
`setUrl( `Guzzle\Http\Message\RequestInterface` $request )`

Set the URL to use with the factory

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request Request that owns the URL

# `protected`
`addSslOptions( `Guzzle\Http\Message\RequestInterface` $request )`

Add SSL options to the stream context

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request Request

# `protected`
`addBodyOptions( `Guzzle\Http\Message\RequestInterface` $request )`

Add body (content) specific options to the context options

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request

# `protected`
`addProxyOptions( `Guzzle\Http\Message\RequestInterface` $request )`

Add proxy parameters to the context if needed

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request Request

# `protected `Guzzle\Stream\StreamInterface``
`createStream( array $params )`

Create the stream for the request with the context options

#### Parameters

$params
  `array`
  $params Parameters of the stream

#### Returns

``Guzzle\Stream\StreamInterface``
# `protected`
`processResponseHeaders( `Guzzle\Stream\StreamInterface` $stream )`

Process response headers

#### Parameters

$stream
  ``Guzzle\Stream\StreamInterface``
  $stream

# `protected resource`
`createResource( callable $callback )`

Create a resource and check to ensure it was created successfully

#### Parameters

$callback
  `callable`
  $callback Closure to invoke that must return a valid resource

#### Returns

`resource`

#### Throws

``Guzzle\Common\Exception\RuntimeException``
on error

### Magic methods summary

## Properties summary

`protected resource` | $context | # Stream context options
`protected array` | $contextOptions | # Stream context
`protected `Guzzle\Http\Url`` | $url | # Stream URL
`protected array` | $lastResponseHeaders | # Last response headers received by the HTTP request