Controller/Request/Http.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Controller
- Version
- $Id: Http.php 24842 2012-05-31 18:31:28Z rob $
\Zend_Controller_Request_Http
Zend_Controller_Request_Http
HTTP request object for use with Zend_Controller family.
- Parent(s)
- \Zend_Controller_Request_Abstract
- Children
- \Zend_Controller_Request_Apache404
- \Zend_Controller_Request_HttpTestCase
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- Uses
- \global\Zend_Controller_Request_Abstract
Constants
Properties

string $_actionKey = 'action'Action key for retrieving action from params
Inherited from: \Zend_Controller_Request_Abstract::$$_actionKey'action'Details- Type
- string
- Inherited_from
- \Zend_Controller_Request_Abstract::$$_actionKey

string $_controller =
- Type
- string
- Inherited_from
- \Zend_Controller_Request_Abstract::$$_controller

string $_controllerKey = 'controller'Controller key for retrieving controller from params
Inherited from: \Zend_Controller_Request_Abstract::$$_controllerKey'controller'Details- Type
- string
- Inherited_from
- \Zend_Controller_Request_Abstract::$$_controllerKey

boolean $_dispatched = falseHas the action been dispatched?
Inherited from: \Zend_Controller_Request_Abstract::$$_dispatchedfalseDetails- Type
- boolean
- Inherited_from
- \Zend_Controller_Request_Abstract::$$_dispatched

string $_moduleKey = 'module'Module key for retrieving module from params
Inherited from: \Zend_Controller_Request_Abstract::$$_moduleKey'module'Details- Type
- string
- Inherited_from
- \Zend_Controller_Request_Abstract::$$_moduleKey

array $_paramSources = array('_GET', '_POST')Allowed parameter sources
array('_GET', '_POST')Details- Type
- array
Methods

__construct(string | \Zend_Uri $uri = null) : voidConstructor
If a $uri is passed, the object will attempt to populate itself using that information.
| Name | Type | Description |
|---|---|---|
| $uri | string | \Zend_Uri |
| Exception | Description |
|---|---|
| \Zend_Controller_Request_Exception | when invalid URI passed |

__get(string $key) : mixedAccess values contained in the superglobals as public members Order of precedence: 1.
GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV
| Name | Type | Description |
|---|---|---|
| $key | string |
| Type | Description |
|---|---|
| mixed |
- See
- \global\http://msdn.microsoft.com/en-us/library/system.web.httprequest.item.aspx

__isset(string $key) : booleanCheck to see if a property is set
| Name | Type | Description |
|---|---|---|
| $key | string |
| Type | Description |
|---|---|
| boolean |

__set(string $key, mixed $value) : voidSet values
In order to follow __get(), which operates on a number of superglobals, setting values through overloading is not allowed and will raise an exception. Use setParam() instead.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $value | mixed |
| Exception | Description |
|---|---|
| \Zend_Controller_Request_Exception |

clearParams() : \Zend_Controller_Request_Abstract
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract |

get(string $key) : mixedAlias to __get
| Name | Type | Description |
|---|---|---|
| $key | string |
| Type | Description |
|---|---|
| mixed |

getActionName() : stringRetrieve the action name
Inherited from: \Zend_Controller_Request_Abstract::getActionName()| Type | Description |
|---|---|
| string |

getAlias(string $name) : string | nullRetrieve an alias
Retrieve the actual key represented by the alias $name.
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| string | null | Returns null when no alias exists |

getBasePath() : stringEverything in REQUEST_URI before PATH_INFO not including the filename

| Type | Description |
|---|---|
| string |

getBaseUrl( $raw = false) : stringEverything in REQUEST_URI before PATH_INFO
| Name | Type | Description |
|---|---|---|
| $raw |
| Type | Description |
|---|---|
| string |

getClientIp(boolean $checkProxy = true) : stringGet the client's IP addres
| Name | Type | Description |
|---|---|---|
| $checkProxy | boolean |
| Type | Description |
|---|---|
| string |

getControllerKey() : stringRetrieve the controller key
Inherited from: \Zend_Controller_Request_Abstract::getControllerKey()| Type | Description |
|---|---|
| string |

getControllerName() : stringRetrieve the controller name
Inherited from: \Zend_Controller_Request_Abstract::getControllerName()| Type | Description |
|---|---|
| string |

getCookie(string $key = null, mixed $default = null) : mixedRetrieve a member of the $_COOKIE superglobal
If no $key is passed, returns the entire $_COOKIE array.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $default | mixed | Default value to use if key not found |
| Type | Description |
|---|---|
| mixed | Returns null if key does not exist |
- Todo
- How to retrieve from nested arrays

getEnv(string $key = null, mixed $default = null) : mixedRetrieve a member of the $_ENV superglobal
If no $key is passed, returns the entire $_ENV array.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $default | mixed | Default value to use if key not found |
| Type | Description |
|---|---|
| mixed | Returns null if key does not exist |

getHeader(string $header) : string | falseReturn the value of the given HTTP header.
Pass the header name as the plain, HTTP-specified header name. Ex.: Ask for 'Accept' to get the Accept header, 'Accept-Encoding' to get the Accept-Encoding header.
| Name | Type | Description |
|---|---|---|
| $header | string | HTTP header name |
| Type | Description |
|---|---|
| string | false | HTTP header value, or false if not found |
| Exception | Description |
|---|---|
| \Zend_Controller_Request_Exception |

getHttpHost() : stringGet the HTTP host.
"Host" ":" host [ ":" port ] ; Section 3.2.2 Note the HTTP Host header is not the same as the URI host. It includes the port while the URI host doesn't.
| Type | Description |
|---|---|
| string |

getModuleName() : stringRetrieve the module name
Inherited from: \Zend_Controller_Request_Abstract::getModuleName()| Type | Description |
|---|---|
| string |

getParam(mixed $key, mixed $default = null) : mixedRetrieve a parameter
Retrieves a parameter from the instance. Priority is in the order of userland parameters (see setParam()), $_GET, $_POST. If a parameter matching the $key is not found, null is returned.
If the $key is an alias, the actual key aliased will be used.
| Name | Type | Description |
|---|---|---|
| $key | mixed | |
| $default | mixed | Default value to use if key not found |
| Type | Description |
|---|---|
| mixed |

getParams() : arrayRetrieve an array of parameters
Retrieves a merged array of parameters, with precedence of userland params (see setParam()), $_GET, $_POST (i.e., values in the userland params will take precedence over all others).
| Type | Description |
|---|---|
| array |

getPathInfo() : stringReturns everything between the BaseUrl and QueryString.
This value is calculated instead of reading PATH_INFO directly from $_SERVER due to cross-platform differences.
| Type | Description |
|---|---|
| string |

getPost(string $key = null, mixed $default = null) : mixedRetrieve a member of the $_POST superglobal
If no $key is passed, returns the entire $_POST array.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $default | mixed | Default value to use if key not found |
| Type | Description |
|---|---|
| mixed | Returns null if key does not exist |
- Todo
- How to retrieve from nested arrays

getQuery(string $key = null, mixed $default = null) : mixedRetrieve a member of the $_GET superglobal
If no $key is passed, returns the entire $_GET array.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $default | mixed | Default value to use if key not found |
| Type | Description |
|---|---|
| mixed | Returns null if key does not exist |
- Todo
- How to retrieve from nested arrays

getRawBody() : string | falseReturn the raw body of the request, if present
| Type | Description |
|---|---|
| string | false | Raw body, or false if not present |

getRequestUri() : stringReturns the REQUEST_URI taking into account platform differences between Apache and IIS
| Type | Description |
|---|---|
| string |

getServer(string $key = null, mixed $default = null) : mixedRetrieve a member of the $_SERVER superglobal
If no $key is passed, returns the entire $_SERVER array.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $default | mixed | Default value to use if key not found |
| Type | Description |
|---|---|
| mixed | Returns null if key does not exist |

getUserParam(string $key, string $default = null) : mixedRetrieve a single user param (i.e, a param specific to the object and not the environment)
Inherited from: \Zend_Controller_Request_Abstract::getUserParam()| Name | Type | Description |
|---|---|---|
| $key | string | |
| $default | string | Default value to use if key not found |
| Type | Description |
|---|---|
| mixed |

getUserParams() : arrayRetrieve only user params (i.e, any param specific to the object and not the environment)
Inherited from: \Zend_Controller_Request_Abstract::getUserParams()| Type | Description |
|---|---|
| array |

has(string $key) : booleanAlias to __isset()
| Name | Type | Description |
|---|---|---|
| $key | string |
| Type | Description |
|---|---|
| boolean |

isDispatched() : booleanDetermine if the request has been dispatched
Inherited from: \Zend_Controller_Request_Abstract::isDispatched()| Type | Description |
|---|---|
| boolean |

isXmlHttpRequest() : booleanIs the request a Javascript XMLHttpRequest?
Should work with Prototype/Script.aculo.us, possibly others.
| Type | Description |
|---|---|
| boolean |

set(string $key, mixed $value) : voidAlias to __set()
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $value | mixed |

setActionKey(string $key) : \Zend_Controller_Request_Abstract
| Name | Type | Description |
|---|---|---|
| $key | string |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract |

setActionName(string $value) : \Zend_Controller_Request_Abstract
| Name | Type | Description |
|---|---|---|
| $value | string |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract |

setAlias(string $name, string $target) : \Zend_Controller_Request_HttpSet a key alias
Set an alias used for key lookups. $name specifies the alias, $target specifies the actual key to use.
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $target | string |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setBasePath(string | null $basePath = null) : \Zend_Controller_Request_HttpSet the base path for the URL
| Name | Type | Description |
|---|---|---|
| $basePath | string | null |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setBaseUrl(mixed $baseUrl = null) : \Zend_Controller_Request_HttpSet the base URL of the request; i.e., the segment leading to the script name
E.g.: - /admin - /myapp - /subdir/index.php
Do not use the full URI when providing the base. The following are examples of what not to use: - http://example.com/admin (should be just /admin) - http://example.com/subdir/index.php (should be just /subdir/index.php)
If no $baseUrl is provided, attempts to determine the base URL from the environment, using SCRIPT_FILENAME, SCRIPT_NAME, PHP_SELF, and ORIG_SCRIPT_NAME in its determination.
| Name | Type | Description |
|---|---|---|
| $baseUrl | mixed |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setControllerKey(string $key) : \Zend_Controller_Request_AbstractSet the controller key
Inherited from: \Zend_Controller_Request_Abstract::setControllerKey()| Name | Type | Description |
|---|---|---|
| $key | string |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract |

setControllerName(string $value) : \Zend_Controller_Request_AbstractSet the controller name to use
Inherited from: \Zend_Controller_Request_Abstract::setControllerName()| Name | Type | Description |
|---|---|---|
| $value | string |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract |

setDispatched(boolean $flag = true) : \Zend_Controller_Request_AbstractSet flag indicating whether or not request has been dispatched
Inherited from: \Zend_Controller_Request_Abstract::setDispatched()| Name | Type | Description |
|---|---|---|
| $flag | boolean |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract |

setModuleKey(string $key) : \Zend_Controller_Request_Abstract
| Name | Type | Description |
|---|---|---|
| $key | string |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract |

setModuleName(string $value) : \Zend_Controller_Request_AbstractSet the module name to use
Inherited from: \Zend_Controller_Request_Abstract::setModuleName()| Name | Type | Description |
|---|---|---|
| $value | string |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Abstract |

setParam(mixed $key, mixed $value) : \Zend_Controller_Request_HttpSet a userland parameter
Uses $key to set a userland parameter. If $key is an alias, the actual key will be retrieved and used to set the parameter.
| Name | Type | Description |
|---|---|---|
| $key | mixed | |
| $value | mixed |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setParamSources( $paramSources = array()) : \Zend_Controller_Request_HttpSet allowed parameter sources
Can be empty array, or contain one or more of '_GET' or '_POST'.
| Name | Type | Description |
|---|---|---|
| $paramSources |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setParams(array $params) : \Zend_Controller_Request_HttpSet parameters
Set one or more parameters. Parameters are set as userland parameters, using the keys specified in the array.
| Name | Type | Description |
|---|---|---|
| $params | array |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setPathInfo(string | null $pathInfo = null) : \Zend_Controller_Request_HttpSet the PATH_INFO string
| Name | Type | Description |
|---|---|---|
| $pathInfo | string | null |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setPost(string | array $spec, null | mixed $value = null) : \Zend_Controller_Request_HttpSet POST values
| Name | Type | Description |
|---|---|---|
| $spec | string | array | |
| $value | null | mixed |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setQuery(string | array $spec, null | mixed $value = null) : \Zend_Controller_Request_HttpSet GET values
| Name | Type | Description |
|---|---|---|
| $spec | string | array | |
| $value | null | mixed |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |

setRequestUri(string $requestUri = null) : \Zend_Controller_Request_HttpSet the REQUEST_URI on which the instance operates
If no request URI is passed, uses the value in $_SERVER['REQUEST_URI'], $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING'].
| Name | Type | Description |
|---|---|---|
| $requestUri | string |
| Type | Description |
|---|---|
| \Zend_Controller_Request_Http |