Documentation

EntityEnclosingRequest extends Request
in package
implements EntityEnclosingRequestInterface

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

Table of Contents

Interfaces

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

Properties

$body  : EntityBodyInterface
$client  : ClientInterface
$curlOptions  : Collection
$eventDispatcher  : EventDispatcherInterface
$expectCutoff  : int
$headerFactory  : HeaderFactoryInterface
$headers  : array<string|int, mixed>
$isRedirect  : bool
$method  : string
$params  : Collection
$password  : string
$postFields  : QueryString
$postFiles  : array<string|int, mixed>
$protocol  : string
$protocolVersion  : string
$response  : Response
$responseBody  : EntityBodyInterface
$state  : string
$url  : Url
$username  : string

Methods

__clone()  : mixed
__construct()  : mixed
__toString()  : string
Get the HTTP request as a string
addCacheControlDirective()  : mixed
addCookie()  : self
Add a Cookie value by name to the Cookie header
addHeader()  : self
Add a header to an existing collection of headers.
addHeaders()  : self
Add and merge in an array of HTTP headers.
addPostFields()  : self
Add POST fields to use in the request
addPostFile()  : self
Add a POST file to the upload
addPostFiles()  : self
Add POST files to use in the upload
addSubscriber()  : self
Add an event subscriber to the dispatcher
canCache()  : mixed
configureRedirects()  : self
Configure how redirects are handled for the request
dispatch()  : Event
Helper to dispatch Guzzle events and set the event name on the event
getAllEvents()  : array<string|int, mixed>
Get a list of all of the events emitted from the class
getBody()  : EntityBodyInterface|null
Get the body of the request if set
getCacheControlDirective()  : mixed
getClient()  : ClientInterface
Get the client used to transport the request
getCookie()  : null|string
Get a cookie value by name
getCookies()  : array<string|int, mixed>
Get an array of Cookies
getCurlOptions()  : Collection
Get the cURL options that will be applied when the cURL handle is created
getEventDispatcher()  : EventDispatcherInterface
Get the EventDispatcher of the request
getHeader()  : Header|null
Retrieve an HTTP header by name. Performs a case-insensitive search of all headers.
getHeaderLines()  : array<string|int, mixed>
Get an array of message header lines (e.g. ["Host: example.com", ...])
getHeaders()  : HeaderCollection
Get all headers as a collection
getHost()  : string
Get the host of the request
getMethod()  : string
Get the HTTP method of the request
getParams()  : Collection
Get application and plugin specific parameters set on the message.
getPassword()  : string|null
Get the password to pass in the URL if set
getPath()  : string
Get the path of the request (e.g. '/', '/index.html')
getPort()  : int|null
Get the port that the request will be sent on if it has been set
getPostField()  : mixed|null
Get a POST field from the request
getPostFields()  : QueryString
Get the post fields that will be used in the request
getPostFile()  : array<string|int, mixed>|null
Get a POST file from the request
getPostFiles()  : array<string|int, mixed>
Returns an associative array of POST field names to PostFileInterface objects
getProtocolVersion()  : string
Get the HTTP protocol version of the request
getQuery()  : QueryString
Get the collection of key value pairs that will be used as the query string in the request
getRawHeaders()  : string
Get the raw message headers as a string
getResource()  : string
Get the resource part of the the request, including the path, query string, and fragment
getResponse()  : Response|null
Get the previously received {@see Response} or NULL if the request has not been sent
getResponseBody()  : EntityBodyInterface
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.
getScheme()  : string
Get the URI scheme of the request (http, https, ftp, etc)
getState()  : string
Get the state of the request. One of 'complete', 'transfer', 'new', 'error'
getTokenizedHeader()  : mixed
getUrl()  : string|Url
Get the full URL of the request (e.g. 'http://www.guzzle-project.com/')
getUsername()  : string|null
Get the username to pass in the URL if set
hasCacheControlDirective()  : mixed
hasHeader()  : bool
Check if the specified header is present.
isRedirect()  : mixed
isResponseBodyRepeatable()  : bool
Determine if the response body is repeatable (readable + seekable)
onRequestError()  : mixed
Default method that will throw exceptions if an unsuccessful response is received.
removeCacheControlDirective()  : mixed
removeCookie()  : self
Remove a specific cookie value by name
removeHeader()  : self
Remove a specific HTTP header.
removePostField()  : self
Remove a POST field or file by name
removePostFile()  : self
Remove a POST file from the request
send()  : Response
Send the request
setAuth()  : self
Set HTTP authorization parameters
setBody()  : self
Set the body of the request
setClient()  : self
Set the client used to transport the request
setEventDispatcher()  : self
Set the EventDispatcher of the request
setExpectHeaderCutoff()  : self
Set the size that the entity body of the request must exceed before adding the Expect: 100-Continue header.
setHeader()  : self
Set an HTTP header and overwrite any existing value for the header
setHeaderFactory()  : self
Set the header factory to use to create headers
setHeaders()  : self
Overwrite all HTTP headers with the supplied array of headers
setHost()  : self
Set the host of the request. Including a port in the host will modify the port of the request.
setIsRedirect()  : mixed
setPath()  : self
Set the path of the request (e.g. '/', '/index.html')
setPort()  : self
Set the port that the request will be sent on
setPostField()  : self
Set a POST field value
setProtocolVersion()  : self
Set the HTTP protocol version of the request (e.g. 1.1 or 1.0)
setResponse()  : self
Manually set a response for the request.
setResponseBody()  : Request
Set the EntityBody that will hold a successful response message's entity body.
setScheme()  : self
Set the URI scheme of the request (http, https, ftp, etc)
setState()  : string
Set the state of the request
setTokenizedHeader()  : mixed
setUrl()  : self
Set the URL of the request
startResponse()  : self
The start of a response has been received for a request and the request is still in progress
getEventArray()  : array<string|int, mixed>
Get an array containing the request and response for event notifications
processPostFields()  : mixed
Determine what type of request should be sent based on post fields
processResponse()  : mixed
Process a received response

Properties

$expectCutoff

protected int $expectCutoff = 1048576

When the size of the body is greater than 1MB, then send Expect: 100-Continue

$headers

protected array<string|int, mixed> $headers

HTTP header collection

$isRedirect

protected bool $isRedirect = false

$method

protected string $method

HTTP method (GET, PUT, POST, DELETE, HEAD, OPTIONS, TRACE)

$password

protected string $password

Auth password

$postFiles

protected array<string|int, mixed> $postFiles = array()

POST files to send with the request

$protocolVersion

protected string $protocolVersion = '1.1'

HTTP protocol version of the message

$state

protected string $state

State of the request object

$username

protected string $username

Authentication username

Methods

__construct()

public __construct(mixed $method, mixed $url[, mixed $headers = array() ]) : mixed
Parameters
$method : mixed

HTTP method

$url : mixed

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 : mixed = array()

HTTP headers

addCacheControlDirective()

public addCacheControlDirective(mixed $directive[, mixed $value = true ]) : mixed
Parameters
$directive : mixed
$value : mixed = true
Tags
codeCoverageIgnore

addCookie()

Add a Cookie value by name to the Cookie header

public addCookie(mixed $name, mixed $value) : self
Parameters
$name : mixed

Name of the cookie to add

$value : mixed

Value to set

Return values
self

addHeader()

Add a header to an existing collection of headers.

public addHeader(mixed $header, mixed $value) : self
Parameters
$header : mixed

Header name to add

$value : mixed

Value of the header

Return values
self

addHeaders()

Add and merge in an array of HTTP headers.

public addHeaders(array<string|int, mixed> $headers) : self
Parameters
$headers : array<string|int, mixed>

Associative array of header data.

Return values
self

addPostFields()

Add POST fields to use in the request

public addPostFields(mixed $fields) : self
Parameters
$fields : mixed

POST fields

Return values
self

addPostFile()

Add a POST file to the upload

public addPostFile(mixed $field[, mixed $filename = null ][, mixed $contentType = null ][, mixed $postname = null ]) : self
Parameters
$field : mixed

POST field to use (e.g. file). Used to reference content from the server.

$filename : mixed = null

Full path to the file. Do not include the @ symbol.

$contentType : mixed = null

Optional Content-Type to add to the Content-Disposition. Default behavior is to guess. Set to false to not specify.

$postname : mixed = null

The name of the file, when posted. (e.g. rename the file)

Return values
self

addPostFiles()

Add POST files to use in the upload

public addPostFiles(array<string|int, mixed> $files) : self
Parameters
$files : array<string|int, mixed>

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

Return values
self

canCache()

public canCache() : mixed

Use Guzzle\Plugin\Cache\DefaultCanCacheStrategy

Tags
codeCoverageIgnore

configureRedirects()

Configure how redirects are handled for the request

public configureRedirects([mixed $strict = false ][, mixed $maxRedirects = 5 ]) : self
Parameters
$strict : mixed = false

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 : mixed = 5

Specify the maximum number of allowed redirects. Set to 0 to disable redirects.

Return values
self

dispatch()

Helper to dispatch Guzzle events and set the event name on the event

public dispatch(mixed $eventName[, array<string|int, mixed> $context = array() ]) : Event
Parameters
$eventName : mixed

Name of the event to dispatch

$context : array<string|int, mixed> = array()

Context of the event

Return values
Event

Returns the created event object

getAllEvents()

Get a list of all of the events emitted from the class

public static getAllEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCacheControlDirective()

public getCacheControlDirective(mixed $directive) : mixed
Parameters
$directive : mixed
Tags
codeCoverageIgnore

getCookie()

Get a cookie value by name

public getCookie(mixed $name) : null|string
Parameters
$name : mixed

Cookie to retrieve

Return values
null|string

getCookies()

Get an array of Cookies

public getCookies() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCurlOptions()

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

public getCurlOptions() : Collection
Return values
Collection

getHeader()

Retrieve an HTTP header by name. Performs a case-insensitive search of all headers.

public getHeader(mixed $header) : Header|null
Parameters
$header : mixed

Header to retrieve.

Return values
Header|null

getHeaderLines()

Get an array of message header lines (e.g. ["Host: example.com", ...])

public getHeaderLines() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHost()

Get the host of the request

public getHost() : string
Return values
string

getMethod()

Get the HTTP method of the request

public getMethod() : string
Return values
string

getPassword()

Get the password to pass in the URL if set

public getPassword() : string|null
Return values
string|null

getPath()

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

public getPath() : string
Return values
string

getPort()

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

public getPort() : int|null
Return values
int|null

getPostField()

Get a POST field from the request

public getPostField(mixed $field) : mixed|null
Parameters
$field : mixed

Field to retrieve

Return values
mixed|null

getPostFile()

Get a POST file from the request

public getPostFile(mixed $fieldName) : array<string|int, mixed>|null
Parameters
$fieldName : mixed

POST fields to retrieve

Return values
array<string|int, mixed>|null

Returns an array wrapping an array of PostFileInterface objects

getPostFiles()

Returns an associative array of POST field names to PostFileInterface objects

public getPostFiles() : array<string|int, mixed>
Return values
array<string|int, mixed>

getProtocolVersion()

Get the HTTP protocol version of the request

public getProtocolVersion() : string
Return values
string

getQuery()

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

public getQuery([mixed $asString = false ]) : QueryString
Parameters
$asString : mixed = false
Return values
QueryString

getRawHeaders()

Get the raw message headers as a string

public getRawHeaders() : string
Return values
string

getResource()

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

public getResource() : string
Return values
string

getResponse()

Get the previously received {@see Response} or NULL if the request has not been sent

public getResponse() : Response|null
Return values
Response|null

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 getResponseBody() : EntityBodyInterface
Return values
EntityBodyInterface

getScheme()

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

public getScheme() : string
Return values
string

getState()

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

public getState() : string
Return values
string

getTokenizedHeader()

public getTokenizedHeader(mixed $header[, mixed $token = ';' ]) : mixed

Use $message->getHeader()->parseParams()

Parameters
$header : mixed
$token : mixed = ';'
Tags
codeCoverageIgnore

getUrl()

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

public getUrl([mixed $asObject = false ]) : string|Url
Parameters
$asObject : mixed = false

Set to TRUE to retrieve the URL as a clone of the URL object owned by the request.

Return values
string|Url

getUsername()

Get the username to pass in the URL if set

public getUsername() : string|null
Return values
string|null

hasCacheControlDirective()

public hasCacheControlDirective(mixed $directive) : mixed
Parameters
$directive : mixed
Tags
codeCoverageIgnore

hasHeader()

Check if the specified header is present.

public hasHeader(mixed $header) : bool
Parameters
$header : mixed

The header to check.

Return values
bool

isRedirect()

public isRedirect() : mixed

Use the history plugin

Tags
codeCoverageIgnore

isResponseBodyRepeatable()

Determine if the response body is repeatable (readable + seekable)

public isResponseBodyRepeatable() : bool

Use getResponseBody()->isSeekable()

Tags
codeCoverageIgnore
Return values
bool

onRequestError()

Default method that will throw exceptions if an unsuccessful response is received.

public static onRequestError(Event $event) : mixed
Parameters
$event : Event

Received

Tags
throws
BadResponseException

if the response is not successful

removeCacheControlDirective()

public removeCacheControlDirective(mixed $directive) : mixed
Parameters
$directive : mixed
Tags
codeCoverageIgnore

removeCookie()

Remove a specific cookie value by name

public removeCookie(mixed $name) : self
Parameters
$name : mixed

Cookie to remove by name

Return values
self

removeHeader()

Remove a specific HTTP header.

public removeHeader(mixed $header) : self
Parameters
$header : mixed

HTTP header to remove.

Return values
self

removePostField()

Remove a POST field or file by name

public removePostField(mixed $field) : self
Parameters
$field : mixed

Name of the POST field or file to remove

Return values
self

removePostFile()

Remove a POST file from the request

public removePostFile(mixed $fieldName) : self
Parameters
$fieldName : mixed

POST file field name to remove

Return values
self

setAuth()

Set HTTP authorization parameters

public setAuth(mixed $user[, mixed $password = '' ][, mixed $scheme = CURLAUTH_BASIC ]) : self
Parameters
$user : mixed

User name or false disable authentication

$password : mixed = ''

Password

$scheme : mixed = CURLAUTH_BASIC

Authentication scheme ('Basic', 'Digest', or a CURLAUTH_* constant (deprecated))

Return values
self

setBody()

Set the body of the request

public setBody(mixed $body[, mixed $contentType = null ]) : self
Parameters
$body : mixed

Body to use in the entity body of the request

$contentType : mixed = null

Content-Type to set. Leave null to use an existing Content-Type or to guess the Content-Type

Return values
self

setExpectHeaderCutoff()

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

public setExpectHeaderCutoff(int|bool $size) : self
Parameters
$size : int|bool

Cutoff in bytes. Set to false to never send the expect header (even with non-seekable data)

Return values
self

setHeader()

Set an HTTP header and overwrite any existing value for the header

public setHeader(mixed $header, mixed $value) : self
Parameters
$header : mixed

Name of the header to set.

$value : mixed

Value to set.

Return values
self

setHeaders()

Overwrite all HTTP headers with the supplied array of headers

public setHeaders(array<string|int, mixed> $headers) : self
Parameters
$headers : array<string|int, mixed>

Associative array of header data.

Return values
self

setHost()

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

public setHost(mixed $host) : self
Parameters
$host : mixed

Host to set (e.g. www.yahoo.com, www.yahoo.com:80)

Return values
self

setIsRedirect()

public setIsRedirect(mixed $isRedirect) : mixed

Use the history plugin (not emitting a warning as this is built-into the RedirectPlugin for now)

Parameters
$isRedirect : mixed
Tags
codeCoverageIgnore

setPath()

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

public setPath(mixed $path) : self
Parameters
$path : mixed

Path to set or array of segments to implode

Return values
self

setPort()

Set the port that the request will be sent on

public setPort(mixed $port) : self
Parameters
$port : mixed

Port number to set

Return values
self

setPostField()

Set a POST field value

public setPostField(mixed $key, mixed $value) : self
Parameters
$key : mixed

Key to set

$value : mixed

Value to set

Return values
self

setProtocolVersion()

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

public setProtocolVersion(mixed $protocol) : self
Parameters
$protocol : mixed

HTTP protocol version to use with the request

Return values
self

setResponse()

Manually set a response for the request.

public setResponse(Response $response[, mixed $queued = false ]) : self

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 : Response

Response object to set

$queued : mixed = false

Set to TRUE to keep the request in a state of not having been sent, but queue the response for send()

Return values
self

Returns a reference to the object.

setResponseBody()

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

public setResponseBody(mixed $body) : Request

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 : mixed

Response body object. Pass a string to attempt to store the response body in a local file.

Return values
Request

setScheme()

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

public setScheme(mixed $scheme) : self
Parameters
$scheme : mixed

Scheme to set

Return values
self

setState()

Set the state of the request

public setState(mixed $state[, array<string|int, mixed> $context = array() ]) : string
Parameters
$state : mixed

State of the request ('complete', 'transfer', 'new', 'error')

$context : array<string|int, mixed> = array()

Contextual information about the state change

Return values
string

Returns the current state of the request (which may have changed due to events being fired)

setTokenizedHeader()

public setTokenizedHeader(mixed $header, mixed $data[, mixed $token = ';' ]) : mixed
Parameters
$header : mixed
$data : mixed
$token : mixed = ';'
Tags
codeCoverageIgnore

setUrl()

Set the URL of the request

public setUrl(mixed $url) : self
Parameters
$url : mixed

|Url Full URL to set including query string

Return values
self

startResponse()

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

public startResponse(Response $response) : self
Parameters
$response : Response

Response that has been received so far

Return values
self

getEventArray()

Get an array containing the request and response for event notifications

protected getEventArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

processPostFields()

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

protected processPostFields() : mixed

processResponse()

Process a received response

protected processResponse([array<string|int, mixed> $context = array() ]) : mixed
Parameters
$context : array<string|int, mixed> = array()

Contextual information

Tags
throws
RequestException|BadResponseException

on unsuccessful responses


        
On this page

Search results