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

# Interface RequestInterface

Generic HTTP request interface

  Guzzle\Http\Message\RequestInterface implements Guzzle\Http\Message\MessageInterface, Guzzle\Common\HasDispatcherInterface

### Direct known implementers

`Guzzle\Http\Message\EntityEnclosingRequestInterface`, `Guzzle\Http\Message\Request`

### Indirect known implementers

`Guzzle\Http\Message\EntityEnclosingRequest`

Namespace: Guzzle\Http\Message
Located at Guzzle/Http/Message/RequestInterface.php

## Methods summary

- `public` `__toString ( )`
- `public` `send ( )`

  Send the request

- `public` `setClient ( Guzzle\Http\ClientInterface $client )`

  Set the client used to transport the request

- `public` `getClient ( )`

  Get the client used to transport the request

- `public` `setUrl ( string $url )`

  Set the URL of the request

- `public` `getUrl ( bool $asObject = false )`

  Get the full URL of the request (e.g. 'http://www.guzzle-project.com/')

- `public` `getResource ( )`

  Get the resource part of the the request, including the path, query string, and fragment

- `public` `getQuery ( )`

  Get the collection of key value pairs that will be used as the query string in the request

- `public` `getMethod ( )`

  Get the HTTP method of the request

- `public` `getScheme ( )`

  Get the URI scheme of the request (http, https, ftp, etc)

- `public` `setScheme ( string $scheme )`

  Set the URI scheme of the request (http, https, ftp, etc)

- `public` `getHost ( )`

  Get the host of the request

- `public` `setHost ( string $host )`

  Set the host of the request. Including a port in the host will modify the port of the request.

- `public` `getPath ( )`

  Get the path of the request (e.g. '/', '/index.html')

- `public` `setPath ( string|array $path )`

  Set the path of the request (e.g. '/', '/index.html')

- `public` `getPort ( )`

  Get the port that the request will be sent on if it has been set

- `public` `setPort ( int $port )`

  Set the port that the request will be sent on

- `public` `getUsername ( )`

  Get the username to pass in the URL if set

- `public` `getPassword ( )`

  Get the password to pass in the URL if set

- `public` `setAuth ( string|bool $user, string $password = '', string $scheme = 'Basic' )`

  Set HTTP authorization parameters

- `public` `getProtocolVersion ( )`

  Get the HTTP protocol version of the request

- `public` `setProtocolVersion ( string $protocol )`

  Set the HTTP protocol version of the request (e.g. 1.1 or 1.0)

- `public` `getResponse ( )`

  Get the previously received `Guzzle\Http\Message\Response` or NULL if the request has not been sent

- `public` `setResponse ( Guzzle\Http\Message\Response $response, bool $queued = false )`

  Manually set a response for the request.

- `public` `startResponse ( Guzzle\Http\Message\Response $response )`

  The start of a response has been received for a request and the request is still in progress

- `public` `setResponseBody ( EntityBodyInterface|string|resource $body )`

  Set the EntityBody that will hold a successful response message's entity body.

- `public` `getResponseBody ( )`

  Get the EntityBody that will hold the resulting response message's entity body. This response body will only be used for successful responses. Intermediate responses (e.g. redirects) will not use the targeted response body.

- `public` `getState ( )`

  Get the state of the request. One of 'complete', 'transfer', 'new', 'error'

- `public` `setState ( string $state, array $context = array() )`

  Set the state of the request

- `public` `getCurlOptions ( )`

  Get the cURL options that will be applied when the cURL handle is created

- `public` `getCookies ( )`

  Get an array of Cookies

- `public` `getCookie ( string $name )`

  Get a cookie value by name

- `public` `addCookie ( string $name, string $value )`

  Add a Cookie value by name to the Cookie header

- `public` `removeCookie ( string $name )`

  Remove a specific cookie value by name

## Methods detail

# `public string`
`__toString( )`

#### Returns

`string`
# `public `Guzzle\Http\Message\Response``
`send( )`

Send the request

#### Returns

``Guzzle\Http\Message\Response``

#### Throws

``Guzzle\Http\Exception\RequestException``
on a request error
# `public `Guzzle\Http\Message\RequestInterface``
`setClient( `Guzzle\Http\ClientInterface` $client )`

Set the client used to transport the request

#### Parameters

$client
  ``Guzzle\Http\ClientInterface``
  $client

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public `Guzzle\Http\ClientInterface``
`getClient( )`

Get the client used to transport the request

#### Returns

``Guzzle\Http\ClientInterface``
$client
# `public `Guzzle\Http\Message\RequestInterface``
`setUrl( string $url )`

Set the URL of the request

#### Parameters

$url
  `string`
  $url|Url Full URL to set including query string

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public string|`Guzzle\Http\Url``
`getUrl( boolean $asObject = false )`

Get the full URL of the request (e.g. 'http://www.guzzle-project.com/')

#### Parameters

$asObject
  `boolean`
  $asObject Set to TRUE to retrieve the URL as a clone of the URL object owned by the request.

#### Returns

`string|`Guzzle\Http\Url``
# `public string`
`getResource( )`

Get the resource part of the the request, including the path, query string, and fragment

#### Returns

`string`
# `public `Guzzle\Http\QueryString``
`getQuery( )`

Get the collection of key value pairs that will be used as the query string in the request

#### Returns

``Guzzle\Http\QueryString``
# `public string`
`getMethod( )`

Get the HTTP method of the request

#### Returns

`string`
# `public string`
`getScheme( )`

Get the URI scheme of the request (http, https, ftp, etc)

#### Returns

`string`
# `public `Guzzle\Http\Message\RequestInterface``
`setScheme( string $scheme )`

Set the URI scheme of the request (http, https, ftp, etc)

#### Parameters

$scheme
  `string`
  $scheme Scheme to set

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public string`
`getHost( )`

Get the host of the request

#### Returns

`string`
# `public `Guzzle\Http\Message\RequestInterface``
`setHost( string $host )`

Set the host of the request. Including a port in the host will modify the port of the request.

#### Parameters

$host
  `string`
  $host Host to set (e.g. www.yahoo.com, www.yahoo.com:80)

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public string`
`getPath( )`

Get the path of the request (e.g. '/', '/index.html')

#### Returns

`string`
# `public `Guzzle\Http\Message\RequestInterface``
`setPath( string|array $path )`

Set the path of the request (e.g. '/', '/index.html')

#### Parameters

$path
  `string|array`
  $path Path to set or array of segments to implode

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public integer|null`
`getPort( )`

Get the port that the request will be sent on if it has been set

#### Returns

`integer|null`
# `public `Guzzle\Http\Message\RequestInterface``
`setPort( integer $port )`

Set the port that the request will be sent on

#### Parameters

$port
  `integer`
  $port Port number to set

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public string|null`
`getUsername( )`

Get the username to pass in the URL if set

#### Returns

`string|null`
# `public string|null`
`getPassword( )`

Get the password to pass in the URL if set

#### Returns

`string|null`
# `public `Guzzle\Http\Message\RequestInterface``
`setAuth( string|boolean $user, string $password = '', string $scheme = 'Basic' )`

Set HTTP authorization parameters

#### Parameters

$user
  `string|boolean`
  $user User name or false disable authentication
$password
  `string`
  $password Password
$scheme
  `string`
  $scheme Authentication scheme ('Basic', 'Digest', or a CURLAUTH_* constant (deprecated))

#### Returns

``Guzzle\Http\Message\RequestInterface``

#### Throws

``Guzzle\Http\Exception\RequestException``

#### Link

http://www.ietf.org/rfc/rfc2617.txt
See the available options for CURLOPT_HTTPAUTH
# `public string`
`getProtocolVersion( )`

Get the HTTP protocol version of the request

#### Returns

`string`
# `public `Guzzle\Http\Message\RequestInterface``
`setProtocolVersion( string $protocol )`

Set the HTTP protocol version of the request (e.g. 1.1 or 1.0)

#### Parameters

$protocol
  `string`
  $protocol HTTP protocol version to use with the request

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public `Guzzle\Http\Message\Response`|null`
`getResponse( )`

Get the previously received `Guzzle\Http\Message\Response` or NULL if the request has not been sent

#### Returns

``Guzzle\Http\Message\Response`|null`
# `public `Guzzle\Http\Message\RequestInterface``
`setResponse( `Guzzle\Http\Message\Response` $response, boolean $queued = false )`

Manually set a response for the request.

This method is useful for specifying a mock response for the request or setting the response using a cache. Manually setting a response will bypass the actual sending of a request.

#### Parameters

$response
  ``Guzzle\Http\Message\Response``
  $response Response object to set
$queued
  `boolean`
  $queued Set to TRUE to keep the request in a state of not having been sent, but queue the response for send()

#### Returns

``Guzzle\Http\Message\RequestInterface``
Returns a reference to the object.
# `public `Guzzle\Http\Message\RequestInterface``
`startResponse( `Guzzle\Http\Message\Response` $response )`

The start of a response has been received for a request and the request is still in progress

#### Parameters

$response
  ``Guzzle\Http\Message\Response``
  $response Response that has been received so far

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public `Guzzle\Http\Message\Request``
`setResponseBody( `Guzzle\Http\EntityBodyInterface`|string|resource $body )`

Set the EntityBody that will hold a successful response message's entity body.

This method should be invoked when you need to send the response's entity body somewhere other than the normal php://temp buffer. For example, you can send the entity body to a socket, file, or some other custom stream.

#### Parameters

$body
  ``Guzzle\Http\EntityBodyInterface`|string|resource`
  $body Response body object. Pass a string to attempt to store the response body in a local file.

#### Returns

``Guzzle\Http\Message\Request``
# `public `Guzzle\Http\EntityBodyInterface``
`getResponseBody( )`

Get the EntityBody that will hold the resulting response message's entity body. This response body will only be used for successful responses. Intermediate responses (e.g. redirects) will not use the targeted response body.

#### Returns

``Guzzle\Http\EntityBodyInterface``
# `public string`
`getState( )`

Get the state of the request. One of 'complete', 'transfer', 'new', 'error'

#### Returns

`string`
# `public string`
`setState( string $state, array $context = array() )`

Set the state of the request

#### Parameters

$state
  `string`
  $state State of the request ('complete', 'transfer', 'new', 'error')
$context
  `array`
  $context Contextual information about the state change

#### Returns

`string`
Returns the current state of the request (which may have changed due to events being fired)
# `public `Guzzle\Common\Collection``
`getCurlOptions( )`

Get the cURL options that will be applied when the cURL handle is created

#### Returns

``Guzzle\Common\Collection``
# `public array`
`getCookies( )`

Get an array of Cookies

#### Returns

`array`
# `public null|string`
`getCookie( string $name )`

Get a cookie value by name

#### Parameters

$name
  `string`
  $name Cookie to retrieve

#### Returns

`null|string`
# `public `Guzzle\Http\Message\RequestInterface``
`addCookie( string $name, string $value )`

Add a Cookie value by name to the Cookie header

#### Parameters

$name
  `string`
  $name Name of the cookie to add
$value
  `string`
  $value Value to set

#### Returns

``Guzzle\Http\Message\RequestInterface``
# `public `Guzzle\Http\Message\RequestInterface``
`removeCookie( string $name )`

Remove a specific cookie value by name

#### Parameters

$name
  `string`
  $name Cookie to remove by name

#### Returns

``Guzzle\Http\Message\RequestInterface``

### Methods inherited from Guzzle\Http\Message\MessageInterface

`addHeader()`, `addHeaders()`, `getHeader()`, `getHeaderLines()`, `getHeaders()`, `getParams()`, `getRawHeaders()`, `hasHeader()`, `removeHeader()`, `setHeader()`, `setHeaders()`

### Methods inherited from Guzzle\Common\HasDispatcherInterface

`addSubscriber()`, `dispatch()`, `getAllEvents()`, `getEventDispatcher()`, `setEventDispatcher()`

### Magic methods summary

## Constants summary

`string` | `STATE_NEW` | `'new'` | #
`string` | `STATE_COMPLETE` | `'complete'` | #
`string` | `STATE_TRANSFER` | `'transfer'` | #
`string` | `STATE_ERROR` | `'error'` | #
`string` | `GET` | `'GET'` | #
`string` | `PUT` | `'PUT'` | #
`string` | `POST` | `'POST'` | #
`string` | `DELETE` | `'DELETE'` | #
`string` | `HEAD` | `'HEAD'` | #
`string` | `CONNECT` | `'CONNECT'` | #
`string` | `OPTIONS` | `'OPTIONS'` | #
`string` | `TRACE` | `'TRACE'` | #
`string` | `PATCH` | `'PATCH'` | #