EntityEnclosingRequestInterface
extends
RequestInterface
in
HTTP request that sends an entity-body in the request message (POST, PUT)
Table of Contents
Constants
- CONNECT = 'CONNECT'
- DELETE = 'DELETE'
- GET = 'GET'
- HEAD = 'HEAD'
- MULTIPART = 'multipart/form-data'
- OPTIONS = 'OPTIONS'
- PATCH = 'PATCH'
- POST = 'POST'
- PUT = 'PUT'
- STATE_COMPLETE = 'complete'
- STATE_ERROR = 'error'
- STATE_NEW = 'new'
- STATE_TRANSFER = 'transfer'
- TRACE = 'TRACE'
- URL_ENCODED = 'application/x-www-form-urlencoded; charset=utf-8'
Methods
- __toString() : string
- 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
- 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
- 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'
- 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
- hasHeader() : bool
- Check if the specified header is present.
- 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
- setHeader() : self
- Set an HTTP header and overwrite any existing value for the header
- 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.
- 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
- 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
Constants
CONNECT
public
mixed
CONNECT
= 'CONNECT'
DELETE
public
mixed
DELETE
= 'DELETE'
GET
public
mixed
GET
= 'GET'
HEAD
public
mixed
HEAD
= 'HEAD'
MULTIPART
public
mixed
MULTIPART
= 'multipart/form-data'
OPTIONS
public
mixed
OPTIONS
= 'OPTIONS'
PATCH
public
mixed
PATCH
= 'PATCH'
POST
public
mixed
POST
= 'POST'
PUT
public
mixed
PUT
= 'PUT'
STATE_COMPLETE
public
mixed
STATE_COMPLETE
= 'complete'
STATE_ERROR
public
mixed
STATE_ERROR
= 'error'
STATE_NEW
public
mixed
STATE_NEW
= 'new'
STATE_TRANSFER
public
mixed
STATE_TRANSFER
= 'transfer'
TRACE
public
mixed
TRACE
= 'TRACE'
URL_ENCODED
public
mixed
URL_ENCODED
= 'application/x-www-form-urlencoded; charset=utf-8'
Methods
__toString()
public
__toString() : string
Return values
stringaddCookie()
Add a Cookie value by name to the Cookie header
public
addCookie(string $name, string $value) : self
Parameters
- $name : string
-
Name of the cookie to add
- $value : string
-
Value to set
Return values
selfaddHeader()
Add a header to an existing collection of headers.
public
addHeader(string $header, string $value) : self
Parameters
- $header : string
-
Header name to add
- $value : string
-
Value of the header
Return values
selfaddHeaders()
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
selfaddPostFields()
Add POST fields to use in the request
public
addPostFields(QueryString|array<string|int, mixed> $fields) : self
Parameters
- $fields : QueryString|array<string|int, mixed>
-
POST fields
Return values
selfaddPostFile()
Add a POST file to the upload
public
addPostFile(string $field[, string $filename = null ][, string $contentType = null ][, string $postname = null ]) : self
Parameters
- $field : string
-
POST field to use (e.g. file). Used to reference content from the server.
- $filename : string = null
-
Full path to the file. Do not include the @ symbol.
- $contentType : string = null
-
Optional Content-Type to add to the Content-Disposition. Default behavior is to guess. Set to false to not specify.
- $postname : string = null
-
The name of the file, when posted. (e.g. rename the file)
Return values
selfaddPostFiles()
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
selfaddSubscriber()
Add an event subscriber to the dispatcher
public
addSubscriber(EventSubscriberInterface $subscriber) : self
Parameters
- $subscriber : EventSubscriberInterface
-
Event subscriber
Return values
selfconfigureRedirects()
Configure how redirects are handled for the request
public
configureRedirects([bool $strict = false ][, int $maxRedirects = 5 ]) : self
Parameters
- $strict : bool = 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 : int = 5
-
Specify the maximum number of allowed redirects. Set to 0 to disable redirects.
Return values
selfdispatch()
Helper to dispatch Guzzle events and set the event name on the event
public
dispatch(string $eventName[, array<string|int, mixed> $context = array() ]) : Event
Parameters
- $eventName : string
-
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>getBody()
Get the body of the request if set
public
getBody() : EntityBodyInterface|null
Return values
EntityBodyInterface|nullgetClient()
Get the client used to transport the request
public
getClient() : ClientInterface
Return values
ClientInterface —$client
getCookie()
Get a cookie value by name
public
getCookie(string $name) : null|string
Parameters
- $name : string
-
Cookie to retrieve
Return values
null|stringgetCookies()
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
CollectiongetEventDispatcher()
Get the EventDispatcher of the request
public
getEventDispatcher() : EventDispatcherInterface
Return values
EventDispatcherInterfacegetHeader()
Retrieve an HTTP header by name. Performs a case-insensitive search of all headers.
public
getHeader(string $header) : Header|null
Parameters
- $header : string
-
Header to retrieve.
Return values
Header|nullgetHeaderLines()
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
HeaderCollectiongetHost()
Get the host of the request
public
getHost() : string
Return values
stringgetMethod()
Get the HTTP method of the request
public
getMethod() : string
Return values
stringgetParams()
Get application and plugin specific parameters set on the message.
public
getParams() : Collection
Return values
CollectiongetPassword()
Get the password to pass in the URL if set
public
getPassword() : string|null
Return values
string|nullgetPath()
Get the path of the request (e.g. '/', '/index.html')
public
getPath() : string
Return values
stringgetPort()
Get the port that the request will be sent on if it has been set
public
getPort() : int|null
Return values
int|nullgetPostField()
Get a POST field from the request
public
getPostField(string $field) : mixed|null
Parameters
- $field : string
-
Field to retrieve
Return values
mixed|nullgetPostFields()
Get the post fields that will be used in the request
public
getPostFields() : QueryString
Return values
QueryStringgetPostFile()
Get a POST file from the request
public
getPostFile(string $fieldName) : array<string|int, mixed>|null
Parameters
- $fieldName : string
-
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
stringgetQuery()
Get the collection of key value pairs that will be used as the query string in the request
public
getQuery() : QueryString
Return values
QueryStringgetRawHeaders()
Get the raw message headers as a string
public
getRawHeaders() : string
Return values
stringgetResource()
Get the resource part of the the request, including the path, query string, and fragment
public
getResource() : string
Return values
stringgetResponse()
Get the previously received {@see Response} or NULL if the request has not been sent
public
getResponse() : Response|null
Return values
Response|nullgetResponseBody()
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
EntityBodyInterfacegetScheme()
Get the URI scheme of the request (http, https, ftp, etc)
public
getScheme() : string
Return values
stringgetState()
Get the state of the request. One of 'complete', 'transfer', 'new', 'error'
public
getState() : string
Return values
stringgetUrl()
Get the full URL of the request (e.g. 'http://www.guzzle-project.com/')
public
getUrl([bool $asObject = false ]) : string|Url
Parameters
- $asObject : bool = false
-
Set to TRUE to retrieve the URL as a clone of the URL object owned by the request.
Return values
string|UrlgetUsername()
Get the username to pass in the URL if set
public
getUsername() : string|null
Return values
string|nullhasHeader()
Check if the specified header is present.
public
hasHeader(string $header) : bool
Parameters
- $header : string
-
The header to check.
Return values
boolremoveCookie()
Remove a specific cookie value by name
public
removeCookie(string $name) : self
Parameters
- $name : string
-
Cookie to remove by name
Return values
selfremoveHeader()
Remove a specific HTTP header.
public
removeHeader(string $header) : self
Parameters
- $header : string
-
HTTP header to remove.
Return values
selfremovePostField()
Remove a POST field or file by name
public
removePostField(string $field) : self
Parameters
- $field : string
-
Name of the POST field or file to remove
Return values
selfremovePostFile()
Remove a POST file from the request
public
removePostFile(string $fieldName) : self
Parameters
- $fieldName : string
-
POST file field name to remove
Return values
selfsend()
Send the request
public
send() : Response
Tags
Return values
ResponsesetAuth()
Set HTTP authorization parameters
public
setAuth(string|bool $user[, string $password = '' ][, string $scheme = 'Basic' ]) : self
Parameters
- $user : string|bool
-
User name or false disable authentication
- $password : string = ''
-
Password
- $scheme : string = 'Basic'
-
Authentication scheme ('Basic', 'Digest', or a CURLAUTH_* constant (deprecated))
Tags
Return values
selfsetBody()
Set the body of the request
public
setBody(string|resource|EntityBodyInterface $body[, string $contentType = null ]) : self
Parameters
- $body : string|resource|EntityBodyInterface
-
Body to use in the entity body of the request
- $contentType : string = null
-
Content-Type to set. Leave null to use an existing Content-Type or to guess the Content-Type
Tags
Return values
selfsetClient()
Set the client used to transport the request
public
setClient(ClientInterface $client) : self
Parameters
- $client : ClientInterface
Return values
selfsetEventDispatcher()
Set the EventDispatcher of the request
public
setEventDispatcher(EventDispatcherInterface $eventDispatcher) : self
Parameters
- $eventDispatcher : EventDispatcherInterface
Return values
selfsetHeader()
Set an HTTP header and overwrite any existing value for the header
public
setHeader(string $header, mixed $value) : self
Parameters
- $header : string
-
Name of the header to set.
- $value : mixed
-
Value to set.
Return values
selfsetHeaders()
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
selfsetHost()
Set the host of the request. Including a port in the host will modify the port of the request.
public
setHost(string $host) : self
Parameters
- $host : string
-
Host to set (e.g. www.yahoo.com, www.yahoo.com:80)
Return values
selfsetPath()
Set the path of the request (e.g. '/', '/index.html')
public
setPath(string|array<string|int, mixed> $path) : self
Parameters
- $path : string|array<string|int, mixed>
-
Path to set or array of segments to implode
Return values
selfsetPort()
Set the port that the request will be sent on
public
setPort(int $port) : self
Parameters
- $port : int
-
Port number to set
Return values
selfsetPostField()
Set a POST field value
public
setPostField(string $key, string $value) : self
Parameters
- $key : string
-
Key to set
- $value : string
-
Value to set
Return values
selfsetProtocolVersion()
Set the HTTP protocol version of the request (e.g. 1.1 or 1.0)
public
setProtocolVersion(string $protocol) : self
Parameters
- $protocol : string
-
HTTP protocol version to use with the request
Return values
selfsetResponse()
Manually set a response for the request.
public
setResponse(Response $response[, bool $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 : bool = 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(EntityBodyInterface|string|resource $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 : EntityBodyInterface|string|resource
-
Response body object. Pass a string to attempt to store the response body in a local file.
Return values
RequestsetScheme()
Set the URI scheme of the request (http, https, ftp, etc)
public
setScheme(string $scheme) : self
Parameters
- $scheme : string
-
Scheme to set
Return values
selfsetState()
Set the state of the request
public
setState(string $state[, array<string|int, mixed> $context = array() ]) : string
Parameters
- $state : string
-
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)
setUrl()
Set the URL of the request
public
setUrl(string $url) : self
Parameters
- $url : string
-
|Url Full URL to set including query string
Return values
selfstartResponse()
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