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

# Class EntityEnclosingRequest

HTTP request that sends an entity-body in the request message (POST, PUT, PATCH, DELETE)

  Guzzle\Http\Message\AbstractMessage implements Guzzle\Http\Message\MessageInterface
  Guzzle\Http\Message\Request implements Guzzle\Http\Message\RequestInterface
  Guzzle\Http\Message\EntityEnclosingRequest implements Guzzle\Http\Message\EntityEnclosingRequestInterface

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

## Methods summary

- `public` `__construct ( string $method, string|Url $url, array|Collection $headers = array() )`
- `public` `__toString ( )`
- `public` `setState ( string $state, array $context = array() )`

  Set the state of the request

- `public` `setBody ( string|resource|EntityBodyInterface $body, string $contentType = null )`

  Set the body of the request

- `public` `getBody ( )`

  Get the body of the request if set

- `public` `setExpectHeaderCutoff ( int|bool $size )`

  Set the size that the entity body of the request must exceed before adding the Expect: 100-Continue header.

- `public` `configureRedirects ( bool $strict = false, int $maxRedirects = 5 )`

  Configure how redirects are handled for the request

- `public` `getPostField ( string $field )`

  Get a POST field from the request

- `public` `getPostFields ( )`

  Get the post fields that will be used in the request

- `public` `setPostField ( string $key, string $value )`

  Set a POST field value

- `public` `addPostFields ( QueryString|array $fields )`

  Add POST fields to use in the request

- `public` `removePostField ( string $field )`

  Remove a POST field or file by name

- `public` `getPostFiles ( )`

  Returns an associative array of POST field names to PostFileInterface objects

- `public` `getPostFile ( string $fieldName )`

  Get a POST file from the request

- `public` `removePostFile ( string $fieldName )`

  Remove a POST file from the request

- `public` `addPostFile ( string $field, string $filename = null, string $contentType = null, string $postname = null )`

  Add a POST file to the upload

- `public` `addPostFiles ( array $files )`

  Add POST files to use in the upload

- `protected` `processPostFields ( )`

  Determine what type of request should be sent based on post fields

## Methods detail

# `public`
`__construct( string $method, string|Url $url, array|Collection $headers = array() )`

#### Parameters

$method
  `string`
  $method HTTP method
$url
  `string|Url`
  $url HTTP URL to connect to. The URI scheme, host header, and URI are parsed from the full URL. If query string parameters are present they will be parsed as well.
$headers
  `array|Collection`
  $headers HTTP headers

#### Overrides

`Guzzle\Http\Message\Request::__construct`
# `public string`
`__toString( )`

#### Returns

`string`

#### Overrides

`Guzzle\Http\Message\Request::__toString`

#### Implementation of

`Guzzle\Http\Message\RequestInterface::__toString()`
# `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)

#### Overrides

`Guzzle\Http\Message\Request::setState`

#### Implementation of

`Guzzle\Http\Message\RequestInterface::setState()`
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`setBody( string|resource|`Guzzle\Http\EntityBodyInterface` $body, string $contentType = null )`

Set the body of the request

#### Parameters

$body
  `string|resource|`Guzzle\Http\EntityBodyInterface``
  $body Body to use in the entity body of the request
$contentType
  `string`
  $contentType Content-Type to set. Leave null to use an existing Content-Type or to guess the Content-Type

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``

#### Throws

``Guzzle\Http\Exception\RequestException``
if the protocol is < 1.1 and Content-Length can not be determined

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::setBody()`
# `public `Guzzle\Http\EntityBodyInterface`|null`
`getBody( )`

Get the body of the request if set

#### Returns

``Guzzle\Http\EntityBodyInterface`|null`

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::getBody()`
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`setExpectHeaderCutoff( integer|boolean $size )`

Set the size that the entity body of the request must exceed before adding the Expect: 100-Continue header.

#### Parameters

$size
  `integer|boolean`
  $size Cutoff in bytes. Set to false to never send the expect header (even with non-seekable data)

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`configureRedirects( boolean $strict = false, integer $maxRedirects = 5 )`

Configure how redirects are handled for the request

#### Parameters

$strict
  `boolean`
  $strict Set to true to follow strict RFC compliance when redirecting POST requests. Most browsers with follow a 301-302 redirect for a POST request with a GET request. This is the default behavior of Guzzle. Enable strict redirects to redirect these responses with a POST rather than a GET request.
$maxRedirects
  `integer`
  $maxRedirects Specify the maximum number of allowed redirects. Set to 0 to disable redirects.

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::configureRedirects()`
# `public mixed|null`
`getPostField( string $field )`

Get a POST field from the request

#### Parameters

$field
  `string`
  $field Field to retrieve

#### Returns

`mixed|null`

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::getPostField()`
# `public `Guzzle\Http\QueryString``
`getPostFields( )`

Get the post fields that will be used in the request

#### Returns

``Guzzle\Http\QueryString``

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::getPostFields()`
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`setPostField( string $key, string $value )`

Set a POST field value

#### Parameters

$key
  `string`
  $key Key to set
$value
  `string`
  $value Value to set

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::setPostField()`
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`addPostFields( `Guzzle\Http\QueryString`|array $fields )`

Add POST fields to use in the request

#### Parameters

$fields
  ``Guzzle\Http\QueryString`|array`
  $fields POST fields

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::addPostFields()`
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`removePostField( string $field )`

Remove a POST field or file by name

#### Parameters

$field
  `string`
  $field Name of the POST field or file to remove

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::removePostField()`
# `public array`
`getPostFiles( )`

Returns an associative array of POST field names to PostFileInterface objects

#### Returns

`array`

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::getPostFiles()`
# `public array|null`
`getPostFile( string $fieldName )`

Get a POST file from the request

#### Parameters

$fieldName
  `string`
  $fieldName POST fields to retrieve

#### Returns

`array|null`
Returns an array wrapping an array of PostFileInterface objects

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::getPostFile()`
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`removePostFile( string $fieldName )`

Remove a POST file from the request

#### Parameters

$fieldName
  `string`
  $fieldName POST file field name to remove

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::removePostFile()`
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`addPostFile( string $field, string $filename = null, string $contentType = null, string $postname = null )`

Add a POST file to the upload

#### Parameters

$field
  `string`
  $field POST field to use (e.g. file). Used to reference content from the server.
$filename
  `string`
  $filename Full path to the file. Do not include the @ symbol.
$contentType
  `string`
  $contentType Optional Content-Type to add to the Content-Disposition. Default behavior is to guess. Set to false to not specify.
$postname
  `string`
  $postname The name of the file, when posted. (e.g. rename the file)

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::addPostFile()`
# `public `Guzzle\Http\Message\EntityEnclosingRequest``
`addPostFiles( array $files )`

Add POST files to use in the upload

#### Parameters

$files
  `array`
  $files An array of POST fields => filenames where filename can be a string or PostFileInterface

#### Returns

``Guzzle\Http\Message\EntityEnclosingRequest``

#### Implementation of

`Guzzle\Http\Message\EntityEnclosingRequestInterface::addPostFiles()`
# `protected`
`processPostFields( )`

Determine what type of request should be sent based on post fields

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

`__clone()`, `addCookie()`, `addSubscriber()`, `dispatch()`, `getAllEvents()`, `getClient()`, `getCookie()`, `getCookies()`, `getCurlOptions()`, `getEventArray()`, `getEventDispatcher()`, `getHost()`, `getMethod()`, `getPassword()`, `getPath()`, `getPort()`, `getProtocolVersion()`, `getQuery()`, `getRawHeaders()`, `getResource()`, `getResponse()`, `getResponseBody()`, `getScheme()`, `getState()`, `getUrl()`, `getUsername()`, `onRequestError()`, `processResponse()`, `removeCookie()`, `send()`, `setAuth()`, `setClient()`, `setEventDispatcher()`, `setHost()`, `setPath()`, `setPort()`, `setProtocolVersion()`, `setResponse()`, `setResponseBody()`, `setScheme()`, `setUrl()`, `startResponse()`

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

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

### Magic methods summary

## Constants summary

### Constants inherited from Guzzle\Http\Message\RequestInterface

`CONNECT`, `DELETE`, `GET`, `HEAD`, `OPTIONS`, `PATCH`, `POST`, `PUT`, `STATE_COMPLETE`, `STATE_ERROR`, `STATE_NEW`, `STATE_TRANSFER`, `TRACE`

### Constants inherited from Guzzle\Http\Message\EntityEnclosingRequestInterface

`MULTIPART`, `URL_ENCODED`

## Properties summary

`protected integer` | $expectCutoff | # When the size of the body is greater than 1MB, then send Expect: 100-Continue
`protected `Guzzle\Http\EntityBodyInterface`` | $body | # $body Body of the request
`protected `Guzzle\Http\QueryString`` | $postFields | # POST fields to use in the EntityBody
`protected array` | $postFiles | # POST files to send with the request

### Properties inherited from Guzzle\Http\Message\Request

`$client`, `$curlOptions`, `$eventDispatcher`, `$isRedirect`, `$method`, `$password`, `$response`, `$responseBody`, `$state`, `$url`, `$username`

### Properties inherited from Guzzle\Http\Message\AbstractMessage

`$headerFactory`, `$headers`, `$params`, `$protocol`, `$protocolVersion`