RequestInterface
extends
MessageInterface, HasDispatcherInterface
in
Generic HTTP request interface
Table of Contents
Constants
- CONNECT = 'CONNECT'
- DELETE = 'DELETE'
- GET = 'GET'
- HEAD = 'HEAD'
- OPTIONS = 'OPTIONS'
- PATCH = 'PATCH'
- POST = 'POST'
- PUT = 'PUT'
- STATE_COMPLETE = 'complete'
- STATE_ERROR = 'error'
- STATE_NEW = 'new'
- STATE_TRANSFER = 'transfer'
- TRACE = 'TRACE'
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.
- addSubscriber() : self
- Add an event subscriber to the dispatcher
- 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
- 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
- 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.
- send() : Response
- Send the request
- setAuth() : self
- Set HTTP authorization parameters
- 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
- 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'
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'
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
selfaddSubscriber()
Add an event subscriber to the dispatcher
public
addSubscriber(EventSubscriberInterface $subscriber) : self
Parameters
- $subscriber : EventSubscriberInterface
-
Event subscriber
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>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(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|nullgetProtocolVersion()
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
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
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
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