Elgg  Version 1.9
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg_Http_Request Class Reference

Public Member Functions

 __construct (array $query=array(), array $request=array(), array $cookies=array(), array $files=array(), array $server=array())
 Create a request. More...
 
 get ($key, $default=null)
 Get a parameter from this request. More...
 
 getRequestUri ()
 Returns the requested URI. More...
 
 getUri ()
 Generates a normalized URI for the Request. More...
 
 getSchemeAndHttpHost ()
 Gets the scheme and HTTP host. More...
 
 getScheme ()
 Gets the request's scheme. More...
 
 getHttpHost ()
 Returns the HTTP host being requested. More...
 
 getHost ()
 Returns the host name. More...
 
 isSecure ()
 Is this request using SSL. More...
 
 getPort ()
 Returns the port on which the request is made. More...
 
 getBaseUrl ()
 Returns the root url from which this request is executed. More...
 
 getPathInfo ()
 Returns the path being requested relative to the executed script. More...
 
 getQueryString ()
 Gets the normalized query string for the Request. More...
 
 getUrlSegments ()
 Get URL segments from the path info. More...
 
 getFirstUrlSegment ()
 Get first URL segment from the path info. More...
 
 getClientIp ()
 Get the IP address of the client. More...
 
 isXmlHttpRequest ()
 Is this an ajax request. More...
 

Static Public Member Functions

static createFromGlobals ()
 Creates a request from PHP's globals. More...
 
static create ($uri, $method= 'GET', $parameters=array(), $cookies=array(), $files=array(), $server=array())
 Creates a Request based on a given URI and configuration. More...
 
static normalizeQueryString ($qs)
 Normalizes a query string. More...
 

Public Attributes

 $query
 
 $request
 
 $cookies
 
 $files
 
 $server
 
 $headers
 

Protected Member Functions

 initialize (array $query=array(), array $request=array(), array $cookies=array(), array $files=array(), array $server=array())
 Initialize the request. More...
 
 stripSlashesIfMagicQuotes ($data)
 Strip slashes if magic quotes is on. More...
 
 prepareHeaders ()
 Get the HTTP headers from server. More...
 
 prepareRequestUri ()
 Set the request URI. More...
 
 prepareBaseUrl ()
 Prepares the base URL. More...
 
 preparePathInfo ()
 Prepares the path info. More...
 

Protected Attributes

 $baseUrl = null
 
 $requestUri = null
 
 $pathInfo = null
 

Detailed Description

Definition at line 37 of file Request.php.

Constructor & Destructor Documentation

Elgg_Http_Request::__construct ( array  $query = array(),
array  $request = array(),
array  $cookies = array(),
array  $files = array(),
array  $server = array() 
)

Create a request.

Parameters
array$queryGET parameters
array$requestPOST parameters
array$cookiesCOOKIE parameters
array$filesFILES parameters
array$serverSERVER parameters

Definition at line 97 of file Request.php.

Member Function Documentation

static Elgg_Http_Request::create (   $uri,
  $method = 'GET',
  $parameters = array(),
  $cookies = array(),
  $files = array(),
  $server = array() 
)
static

Creates a Request based on a given URI and configuration.

The information contained in the URI always take precedence over the other information (server and parameters).

Parameters
string$uriThe URI
string$methodThe HTTP method
array$parametersThe query (GET) or request (POST) parameters
array$cookiesThe request cookies ($_COOKIE)
array$filesThe request files ($_FILES)
array$serverThe server parameters ($_SERVER)
Returns
Elgg_Http_Request

Definition at line 150 of file Request.php.

static Elgg_Http_Request::createFromGlobals ( )
static

Creates a request from PHP's globals.

Returns
Elgg_Http_Request

Definition at line 131 of file Request.php.

Elgg_Http_Request::get (   $key,
  $default = null 
)

Get a parameter from this request.

It is better to get parameters from the appropriate public property (query, request).

Parameters
string$keyThe key
mixed$defaultThe default value
Returns
mixed

Definition at line 279 of file Request.php.

Elgg_Http_Request::getBaseUrl ( )

Returns the root url from which this request is executed.

The base URL never ends with a /. If the URL directly calls the executed script (e.g. index.php), this is included.

Suppose Elgg is installed at http://localhost/mysite/ :

Returns
string The raw url (i.e. not urldecoded)

Definition at line 412 of file Request.php.

Elgg_Http_Request::getClientIp ( )

Get the IP address of the client.

Returns
string

Definition at line 494 of file Request.php.

Elgg_Http_Request::getFirstUrlSegment ( )

Get first URL segment from the path info.

See also
Elgg_Http_Request::getUrlSegments()
Returns
string

Definition at line 480 of file Request.php.

Elgg_Http_Request::getHost ( )

Returns the host name.

Returns
string
Exceptions
UnexpectedValueExceptionwhen the host name is invalid

Definition at line 360 of file Request.php.

Elgg_Http_Request::getHttpHost ( )

Returns the HTTP host being requested.

The port name will be appended to the host if it's non-standard.

Returns
string

Definition at line 342 of file Request.php.

Elgg_Http_Request::getPathInfo ( )

Returns the path being requested relative to the executed script.

The path info always starts with a /, does not contain the query string, and does not include the path to the Elgg installation.

Suppose Elgg is installed at http://localhost/mysite/ :

Returns
string The raw path (i.e. not urldecoded)

Definition at line 435 of file Request.php.

Elgg_Http_Request::getPort ( )

Returns the port on which the request is made.

Returns
string

Definition at line 395 of file Request.php.

Elgg_Http_Request::getQueryString ( )

Gets the normalized query string for the Request.

It builds a normalized query string, where keys/value pairs are alphabetized and have consistent escaping.

Returns
string|null A normalized query string for the Request

Definition at line 451 of file Request.php.

Elgg_Http_Request::getRequestUri ( )

Returns the requested URI.

Returns
string The raw URI (i.e. not urldecoded)

Definition at line 294 of file Request.php.

Elgg_Http_Request::getScheme ( )

Gets the request's scheme.

Returns
string

Definition at line 331 of file Request.php.

Elgg_Http_Request::getSchemeAndHttpHost ( )

Gets the scheme and HTTP host.

Includes port if non-standard.

Returns
string The scheme and HTTP host

Definition at line 322 of file Request.php.

Elgg_Http_Request::getUri ( )

Generates a normalized URI for the Request.

Returns
string

Definition at line 307 of file Request.php.

Elgg_Http_Request::getUrlSegments ( )

Get URL segments from the path info.

See also
Elgg_Http_Request::getPathInfo()
Returns
array

Definition at line 464 of file Request.php.

Elgg_Http_Request::initialize ( array  $query = array(),
array  $request = array(),
array  $cookies = array(),
array  $files = array(),
array  $server = array() 
)
protected

Initialize the request.

Parameters
array$queryGET parameters
array$requestPOST parameters
array$cookiesCOOKIE parameters
array$filesFILES parameters
array$serverSERVER parameters
Returns
void

Definition at line 112 of file Request.php.

Elgg_Http_Request::isSecure ( )

Is this request using SSL.

Returns
bool

Definition at line 386 of file Request.php.

Elgg_Http_Request::isXmlHttpRequest ( )

Is this an ajax request.

Returns
bool

Definition at line 515 of file Request.php.

static Elgg_Http_Request::normalizeQueryString (   $qs)
static

Normalizes a query string.

It builds a normalized query string, where keys/value pairs are alphabetized, have consistent escaping and unneeded delimiters are removed.

Parameters
string$qsQuery string
Returns
string A normalized query string for the Request

Definition at line 234 of file Request.php.

Elgg_Http_Request::prepareBaseUrl ( )
protected

Prepares the base URL.

Returns
string

Definition at line 574 of file Request.php.

Elgg_Http_Request::prepareHeaders ( )
protected

Get the HTTP headers from server.

Returns
array

Definition at line 539 of file Request.php.

Elgg_Http_Request::preparePathInfo ( )
protected

Prepares the path info.

Returns
string path info

Definition at line 639 of file Request.php.

Elgg_Http_Request::prepareRequestUri ( )
protected

Set the request URI.

The Symfony Request object handles proxies and IIS rewrites. We are not yet.

Returns
string

Definition at line 565 of file Request.php.

Elgg_Http_Request::stripSlashesIfMagicQuotes (   $data)
protected

Strip slashes if magic quotes is on.

Parameters
mixed$dataData to strip slashes from
Returns
mixed

Definition at line 526 of file Request.php.

Member Data Documentation

Elgg_Http_Request::$baseUrl = null
protected

Definition at line 76 of file Request.php.

Elgg_Http_Request::$cookies

Definition at line 53 of file Request.php.

Elgg_Http_Request::$files

Definition at line 59 of file Request.php.

Elgg_Http_Request::$headers

Definition at line 71 of file Request.php.

Elgg_Http_Request::$pathInfo = null
protected

Definition at line 86 of file Request.php.

Elgg_Http_Request::$query

Definition at line 41 of file Request.php.

Elgg_Http_Request::$request

Definition at line 47 of file Request.php.

Elgg_Http_Request::$requestUri = null
protected

Definition at line 81 of file Request.php.

Elgg_Http_Request::$server

Definition at line 65 of file Request.php.


The documentation for this class was generated from the following file: