Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
Request Class Reference

HTTP Request. More...

Public Member Functions

 setMethod ($method)
 Set the method for this request.
 
 getMethod ()
 Return the method for this request.
 
 setUri ($uri)
 Set the URI/URL for this request, this can be a string or an instance of Zend.
 
 getUri ()
 Return the URI for this request object.
 
 getUriString ()
 Return the URI for this request object as a string.
 
 setQuery (ParametersInterface $query)
 Provide an alternate Parameter Container implementation for query parameters in this object, (this is NOT the primary API for value setting, for that see getQuery())
 
 getQuery ($name=null, $default=null)
 Return the parameter container responsible for query parameters or a single query parameter.
 
 setPost (ParametersInterface $post)
 Provide an alternate Parameter Container implementation for post parameters in this object, (this is NOT the primary API for value setting, for that see getPost())
 
 getPost ($name=null, $default=null)
 Return the parameter container responsible for post parameters or a single post parameter.
 
 getCookie ()
 Return the Cookie header, this is the same as calling $request->getHeaders()->get('Cookie');.
 
 setFiles (ParametersInterface $files)
 Provide an alternate Parameter Container implementation for file parameters in this object, (this is NOT the primary API for value setting, for that see getFiles())
 
 getFiles ($name=null, $default=null)
 Return the parameter container responsible for file parameters or a single file.
 
 getHeaders ($name=null, $default=false)
 Return the header container responsible for headers or all headers of a certain name/type.
 
 getHeader ($name, $default=false)
 Get all headers of a certain name/type.
 
 isOptions ()
 Is this an OPTIONS method request?
 
 isPropFind ()
 Is this a PROPFIND method request?
 
 isGet ()
 Is this a GET method request?
 
 isHead ()
 Is this a HEAD method request?
 
 isPost ()
 Is this a POST method request?
 
 isPut ()
 Is this a PUT method request?
 
 isDelete ()
 Is this a DELETE method request?
 
 isTrace ()
 Is this a TRACE method request?
 
 isConnect ()
 Is this a CONNECT method request?
 
 isPatch ()
 Is this a PATCH method request?
 
 isXmlHttpRequest ()
 Is the request a Javascript XMLHttpRequest?
 
 isFlashRequest ()
 Is this a Flash request?
 
 renderRequestLine ()
 Return the formatted request line (first line) for this http request.
 
 toString ()
 
 getAllowCustomMethods ()
 
 setAllowCustomMethods ($strictMethods)
 
- Public Member Functions inherited from AbstractMessage
 setVersion ($version)
 Set the HTTP version for this object, one of 1.0 or 1.1 (AbstractMessage::VERSION_10, AbstractMessage::VERSION_11)
 
 getVersion ()
 Return the HTTP version for this request.
 
 setHeaders (Headers $headers)
 Provide an alternate Parameter Container implementation for headers in this object, (this is NOT the primary API for value setting, for that see getHeaders())
 
 getHeaders ()
 Return the header container responsible for headers.
 
 __toString ()
 Allow PHP casting of this object.
 
- Public Member Functions inherited from Message
 setMetadata ($spec, $value=null)
 Set message metadata.
 
 getMetadata ($key=null, $default=null)
 Retrieve all metadata or a single metadatum as specified by key.
 
 setContent ($value)
 Set message content.
 
 getContent ()
 Get message content.
 
 toString ()
 
- Public Member Functions inherited from MessageInterface
 getMetadata ($key=null)
 Get metadata.
 

Static Public Member Functions

static fromString ($string, $allowCustomMethods=true)
 A factory that produces a Request object from a well-formed Http Request string.
 

Public Attributes

const METHOD_OPTIONS = 'OPTIONS'
 #@+ string METHOD constant names
 
const METHOD_GET = 'GET'
 
const METHOD_HEAD = 'HEAD'
 
const METHOD_POST = 'POST'
 
const METHOD_PUT = 'PUT'
 
const METHOD_DELETE = 'DELETE'
 
const METHOD_TRACE = 'TRACE'
 
const METHOD_CONNECT = 'CONNECT'
 
const METHOD_PATCH = 'PATCH'
 
const METHOD_PROPFIND = 'PROPFIND'
 
- Public Attributes inherited from AbstractMessage
const VERSION_10 = '1.0'
 #@+ string Version constant numbers
 
const VERSION_11 = '1.1'
 

Protected Attributes

 $method = self::METHOD_GET
 
 $allowCustomMethods = true
 
 $uri = null
 
 $queryParams = null
 
 $postParams = null
 
 $fileParams = null
 
- Protected Attributes inherited from AbstractMessage
 $version = self::VERSION_11
 
 $headers = null
 
- Protected Attributes inherited from Message
 $metadata = []
 
 $content = ''
 

Detailed Description

HTTP Request.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5

Member Function Documentation

static fromString (   $string,
  $allowCustomMethods = true 
)
static

A factory that produces a Request object from a well-formed Http Request string.

Parameters
string$string
bool$allowCustomMethods
Exceptions
Exception\InvalidArgumentException
Returns
Request
getAllowCustomMethods ( )
Returns
boolean
getCookie ( )

Return the Cookie header, this is the same as calling $request->getHeaders()->get('Cookie');.

$request->getHeaders()->get('Cookie');

Returns
Header|bool
getFiles (   $name = null,
  $default = null 
)

Return the parameter container responsible for file parameters or a single file.

Parameters
string | null$nameParameter name to retrieve, or null to get the whole container.
mixed | null$defaultDefault value to use when the parameter is missing.
Returns
ParametersInterface|mixed
getHeader (   $name,
  $default = false 
)

Get all headers of a certain name/type.

See Also
Request::getHeaders()
Parameters
string | null$nameHeader name to retrieve, or null to get the whole container.
mixed | null$defaultDefault value to use when the requested header is missing.
Returns
|bool||
getHeaders (   $name = null,
  $default = false 
)

Return the header container responsible for headers or all headers of a certain name/type.

See Also
::get()
Parameters
string | null$nameHeader name to retrieve, or null to get the whole container.
mixed | null$defaultDefault value to use when the requested header is missing.
Returns
|bool||
getMethod ( )

Return the method for this request.

Returns
string
getPost (   $name = null,
  $default = null 
)

Return the parameter container responsible for post parameters or a single post parameter.

Parameters
string | null$nameParameter name to retrieve, or null to get the whole container.
mixed | null$defaultDefault value to use when the parameter is missing.
Returns
|mixed
getQuery (   $name = null,
  $default = null 
)

Return the parameter container responsible for query parameters or a single query parameter.

Parameters
string | null$nameParameter name to retrieve, or null to get the whole container.
mixed | null$defaultDefault value to use when the parameter is missing.
Returns
|mixed
getUri ( )

Return the URI for this request object.

Returns
HttpUri
getUriString ( )

Return the URI for this request object as a string.

Returns
string
isConnect ( )

Is this a CONNECT method request?

Returns
bool
isDelete ( )

Is this a DELETE method request?

Returns
bool
isFlashRequest ( )

Is this a Flash request?

Returns
bool
isGet ( )

Is this a GET method request?

Returns
bool
isHead ( )

Is this a HEAD method request?

Returns
bool
isOptions ( )

Is this an OPTIONS method request?

Returns
bool
isPatch ( )

Is this a PATCH method request?

Returns
bool
isPost ( )

Is this a POST method request?

Returns
bool
isPropFind ( )

Is this a PROPFIND method request?

Returns
bool
isPut ( )

Is this a PUT method request?

Returns
bool
isTrace ( )

Is this a TRACE method request?

Returns
bool
isXmlHttpRequest ( )

Is the request a Javascript XMLHttpRequest?

Should work with Prototype/Script.aculo.us, possibly others.

Returns
bool
renderRequestLine ( )

Return the formatted request line (first line) for this http request.

Returns
string
setAllowCustomMethods (   $strictMethods)
Parameters
boolean$strictMethods
setFiles ( ParametersInterface  $files)

Provide an alternate Parameter Container implementation for file parameters in this object, (this is NOT the primary API for value setting, for that see getFiles())

Parameters
ParametersInterface$files
Returns
Request
setMethod (   $method)

Set the method for this request.

Parameters
string$method
Returns
Request
Exceptions
Exception\InvalidArgumentException
setPost ( ParametersInterface  $post)

Provide an alternate Parameter Container implementation for post parameters in this object, (this is NOT the primary API for value setting, for that see getPost())

Parameters
\Zend\Stdlib\ParametersInterface$post
Returns
Request
setQuery ( ParametersInterface  $query)

Provide an alternate Parameter Container implementation for query parameters in this object, (this is NOT the primary API for value setting, for that see getQuery())

Parameters
\Zend\Stdlib\ParametersInterface$query
Returns
Request
setUri (   $uri)

Set the URI/URL for this request, this can be a string or an instance of Zend.

Exceptions
Exception\InvalidArgumentException
Parameters
string | HttpUri$uri
Returns
Request
toString ( )
Returns
string

Member Data Documentation

$allowCustomMethods = true
protected
$fileParams = null
protected
$method = self::METHOD_GET
protected
$postParams = null
protected
$queryParams = null
protected
$uri = null
protected
const METHOD_CONNECT = 'CONNECT'
const METHOD_DELETE = 'DELETE'
const METHOD_GET = 'GET'
const METHOD_HEAD = 'HEAD'
const METHOD_OPTIONS = 'OPTIONS'

#@+ string METHOD constant names

const METHOD_PATCH = 'PATCH'
const METHOD_POST = 'POST'
const METHOD_PROPFIND = 'PROPFIND'
const METHOD_PUT = 'PUT'
const METHOD_TRACE = 'TRACE'