EntityEnclosingRequest
extends Request
in package
implements
EntityEnclosingRequestInterface
HTTP request that sends an entity-body in the request message (POST, PUT, PATCH, DELETE)
Interfaces, Classes and Traits
- EntityEnclosingRequestInterface
- HTTP request that sends an entity-body in the request message (POST, PUT)
Table of Contents
- $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
- __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() : mixed
- canCache() : mixed
- configureRedirects() : self
- Configure how redirects are handled for the request
- dispatch() : mixed
- getAllEvents() : mixed
- 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() : mixed
- 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() : mixed
- 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() : mixed
- 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
$body
protected
EntityBodyInterface
$body
Body of the request
$client
protected
ClientInterface
$client
$curlOptions
protected
Collection
$curlOptions
cURL specific transfer options
$eventDispatcher
protected
EventDispatcherInterface
$eventDispatcher
$expectCutoff
protected
int
$expectCutoff
= 1048576
When the size of the body is greater than 1MB, then send Expect: 100-Continue
$headerFactory
protected
HeaderFactoryInterface
$headerFactory
$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)
$params
protected
Collection
$params
Custom message parameters that are extendable by plugins
$password
protected
string
$password
Auth password
$postFields
protected
QueryString
$postFields
POST fields to use in the EntityBody
$postFiles
protected
array<string|int, mixed>
$postFiles
= array()
POST files to send with the request
$protocol
protected
string
$protocol
= 'HTTP'
Message protocol
$protocolVersion
protected
string
$protocolVersion
= '1.1'
HTTP protocol version of the message
$response
protected
Response
$response
Response of the request
$responseBody
protected
EntityBodyInterface
$responseBody
Response body
$state
protected
string
$state
State of the request object
$url
protected
Url
$url
HTTP Url
$username
protected
string
$username
Authentication username
Methods
__clone()
public
__clone() : mixed
Return values
mixed —__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
Return values
mixed —__toString()
Get the HTTP request as a string
public
__toString() : string
Return values
string —addCacheControlDirective()
public
addCacheControlDirective(mixed $directive[, mixed $value = true ]) : mixed
Parameters
- $directive : mixed
- $value : mixed = true
Tags
Return values
mixed —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 —addSubscriber()
public
addSubscriber(EventSubscriberInterface $subscriber) : mixed
Parameters
- $subscriber : EventSubscriberInterface
Return values
mixed —canCache()
public
canCache() : mixed
Tags
Return values
mixed —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()
public
dispatch(mixed $eventName[, array<string|int, mixed> $context = array() ]) : mixed
Parameters
- $eventName : mixed
- $context : array<string|int, mixed> = array()
Return values
mixed —getAllEvents()
public
static getAllEvents() : mixed
Return values
mixed —getBody()
Get the body of the request if set
public
getBody() : EntityBodyInterface|null
Return values
EntityBodyInterface|null —getCacheControlDirective()
public
getCacheControlDirective(mixed $directive) : mixed
Parameters
- $directive : mixed
Tags
Return values
mixed —getClient()
Get the client used to transport the request
public
getClient() : ClientInterface
Return values
ClientInterface —$client
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 —getEventDispatcher()
public
getEventDispatcher() : mixed
Return values
mixed —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> —getHeaders()
Get all headers as a collection
public
getHeaders() : HeaderCollection
Return values
HeaderCollection —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 —getParams()
Get application and plugin specific parameters set on the message.
public
getParams() : Collection
Return values
Collection —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 —getPostFields()
Get the post fields that will be used in the request
public
getPostFields() : QueryString
Return values
QueryString —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()
public
getRawHeaders() : mixed
Return values
mixed —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
Parameters
- $header : mixed
- $token : mixed = ';'
Tags
Return values
mixed —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
Return values
mixed —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
Tags
Return values
mixed —isResponseBodyRepeatable()
Determine if the response body is repeatable (readable + seekable)
public
isResponseBodyRepeatable() : bool
Tags
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
Return values
mixed —removeCacheControlDirective()
public
removeCacheControlDirective(mixed $directive) : mixed
Parameters
- $directive : mixed
Tags
Return values
mixed —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 —send()
Send the request
public
send() : Response
Return values
Response —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 —setClient()
Set the client used to transport the request
public
setClient(ClientInterface $client) : self
Parameters
- $client : ClientInterface
Return values
self —setEventDispatcher()
public
setEventDispatcher(EventDispatcherInterface $eventDispatcher) : mixed
Parameters
- $eventDispatcher : EventDispatcherInterface
Return values
mixed —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 —setHeaderFactory()
Set the header factory to use to create headers
public
setHeaderFactory(HeaderFactoryInterface $factory) : self
Parameters
- $factory : HeaderFactoryInterface
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
Parameters
- $isRedirect : mixed
Tags
Return values
mixed —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
Return values
mixed —setUrl()
Set the URL of the request
public
setUrl(mixed $url) : self
Parameters
- $url : mixed
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
Return values
mixed —processResponse()
Process a received response
protected
processResponse([array<string|int, mixed> $context = array() ]) : mixed
Parameters
- $context : array<string|int, mixed> = array()
-
Contextual information