Class Sabre_HTTP_Request

Description

HTTP Request information

This object can be used to easily access information about an HTTP request. It can additionally be used to create 'mock' requests.

This class mostly operates indepentend, but because of the nature of a single request per run it can operate as a singleton. For more information check out the behaviour around 'defaultInputStream'.

  • author: Evert Pot (http://www.rooftopsolutions.nl/)
  • copyright: Copyright (C) 2010 Rooftop Solutions. All rights reserved.
  • license: Modified BSD License

Located in /sources_custom/Sabre/HTTP/Request.php (line 19)


	
			
Variable Summary
static resource $defaultInputStream
resource $body
string $_SERVER
Method Summary
Sabre_HTTP_Request __construct ([array $serverData = null])
void getAbsoluteUri ()
resource getBody ([bool $asString = false])
string getHeader (string $name)
array getHeaders ()
string getMethod ()
string getQueryString ()
string getRawServerValue (string $field)
string getUri ()
void setBody (mixed $body, [bool $setAsDefaultInputStream = false])
Variables
static resource $defaultInputStream = null (line 44)

This will be set as the 'default' inputStream for a specific HTTP request We sometimes need to retain, or rebuild this if we need multiple runs of parsing the original HTTP request.

resource $body = null (line 35)

The request body, if any.

This is stored in the form of a stream resource.

  • access: protected
string $_SERVER (line 26)

PHP's $_SERVER data

  • access: protected
Methods
Constructor __construct (line 54)

Sets up the object

The serverData array can be used to override usage of PHP's global _SERVER variable.

  • access: public
Sabre_HTTP_Request __construct ([array $serverData = null])
  • array $serverData
getAbsoluteUri (line 128)

Will return protocol + the hostname + the uri

  • access: public
void getAbsoluteUri ()
getBody (line 156)

Returns the HTTP request body body

This method returns a readable stream resource. If the asString parameter is set to true, a string is sent instead.

  • access: public
resource getBody ([bool $asString = false])
  • bool $asString: asString
getHeader (line 69)

Returns the value for a specific http header.

This method returns null if the header did not exist.

  • access: public
string getHeader (string $name)
  • string $name
getHeaders (line 84)

Returns all (known) HTTP headers.

All headers are converted to lower-case, and additionally all underscores are automatically converted to dashes

  • access: public
array getHeaders ()
getMethod (line 106)

Returns the HTTP request method

This is for example POST or GET

  • access: public
string getMethod ()
getQueryString (line 141)

Returns everything after the ? from the current url

  • access: public
string getQueryString ()
getRawServerValue (line 213)

Returns a specific item from the _SERVER array.

Do not rely on this feature, it is for internal use only.

  • access: public
string getRawServerValue (string $field)
  • string $field
getUri (line 117)

Returns the requested uri

  • access: public
string getUri ()
setBody (line 187)

Sets the contents of the HTTP requet body

This method can either accept a string, or a readable stream resource.

If the setAsDefaultInputStream is set to true, it means for this run of the script the supplied body will be used instead of php://input.

  • access: public
void setBody (mixed $body, [bool $setAsDefaultInputStream = false])
  • mixed $body
  • bool $setAsDefaultInputStream

Documentation generated on Sun, 02 Jan 2011 23:23:45 +0000 by phpDocumentor 1.4.3