Controller/Request/Http.php

Show: PublicProtectedPrivateinherited
Table of Contents
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 license@zend.com 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

Package: Zend\Controller\Request
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

>VConstant  SCHEME_HTTP = 'http'
Scheme for http
>VConstant  SCHEME_HTTPS = 'https'
Scheme for https

Properties

>VPropertyprotectedstring $_action
inherited
Action
Inherited from: \Zend_Controller_Request_Abstract::$$_action
Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_action  
>VPropertyprotectedstring $_actionKey = 'action'
inherited
Action key for retrieving action from params
Inherited from: \Zend_Controller_Request_Abstract::$$_actionKey
Default value'action'Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_actionKey  
>VPropertyprotectedarray $_aliases = array()
Alias keys for request parameters
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_basePath = null
Base path of request
Default valuenullDetails
Type
string
>VPropertyprotectedstring $_baseUrl = null
Base URL of request
Default valuenullDetails
Type
string
>VPropertyprotectedstring $_controller
inherited
Controller
Inherited from: \Zend_Controller_Request_Abstract::$$_controller
Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_controller  
>VPropertyprotectedstring $_controllerKey = 'controller'
inherited
Controller key for retrieving controller from params
Inherited from: \Zend_Controller_Request_Abstract::$$_controllerKey
Default value'controller'Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_controllerKey  
>VPropertyprotectedboolean $_dispatched = false
inherited
Has the action been dispatched?
Inherited from: \Zend_Controller_Request_Abstract::$$_dispatched
Default valuefalseDetails
Type
boolean
Inherited_from
\Zend_Controller_Request_Abstract::$$_dispatched  
>VPropertyprotectedstring $_module
inherited
Module
Inherited from: \Zend_Controller_Request_Abstract::$$_module
Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_module  
>VPropertyprotectedstring $_moduleKey = 'module'
inherited
Module key for retrieving module from params
Inherited from: \Zend_Controller_Request_Abstract::$$_moduleKey
Default value'module'Details
Type
string
Inherited_from
\Zend_Controller_Request_Abstract::$$_moduleKey  
>VPropertyprotectedarray $_paramSources = array('_GET', '_POST')
Allowed parameter sources
Default valuearray('_GET', '_POST')Details
Type
array
>VPropertyprotectedarray $_params = array()
Instance parameters
Default valuearray()Details
Type
array
>VPropertyprotectedstring $_pathInfo = ''
PATH_INFO
Default value''Details
Type
string
>VPropertyprotectedstring|false $_rawBody
Raw request body
Details
Type
string | false
>VPropertyprotected\string; $_requestUri
REQUEST_URI
Details
Type
\string;

Methods

methodpublic__construct(string | \Zend_Uri $uri = null) : void

Constructor

If a $uri is passed, the object will attempt to populate itself using that information.

Parameters
NameTypeDescription
$uristring | \Zend_Uri
Throws
ExceptionDescription
\Zend_Controller_Request_Exceptionwhen invalid URI passed
methodpublic__get(string $key) : mixed

Access values contained in the superglobals as public members Order of precedence: 1.

GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
Details
See
\http://msdn.microsoft.com/en-us/library/system.web.httprequest.item.aspx  
methodpublic__isset(string $key) : boolean

Check to see if a property is set

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
boolean
methodpublic__set(string $key, mixed $value) : void

Set 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.

Parameters
NameTypeDescription
$keystring
$valuemixed
Throws
ExceptionDescription
\Zend_Controller_Request_Exception
methodpublicclearParams() : \Zend_Controller_Request_Abstract
inherited

Unset all user parameters

Inherited from: \Zend_Controller_Request_Abstract::clearParams()
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicget(string $key) : mixed

Alias to __get

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
methodpublicgetActionKey() : string
inherited

Retrieve the action key

Inherited from: \Zend_Controller_Request_Abstract::getActionKey()
Returns
TypeDescription
string
methodpublicgetActionName() : string
inherited

Retrieve the action name

Inherited from: \Zend_Controller_Request_Abstract::getActionName()
Returns
TypeDescription
string
methodpublicgetAlias(string $name) : string | null

Retrieve an alias

Retrieve the actual key represented by the alias $name.

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string | nullReturns null when no alias exists
methodpublicgetAliases() : array

Retrieve the list of all aliases

Returns
TypeDescription
array
methodpublicgetBasePath() : string

Everything in REQUEST_URI before PATH_INFO not including the filename

Returns
TypeDescription
string
methodpublicgetBaseUrl( $raw = false) : string

Everything in REQUEST_URI before PATH_INFO

Parameters
NameTypeDescription
$raw
Returns
TypeDescription
string
methodpublicgetClientIp(boolean $checkProxy = true) : string

Get the client's IP addres

Parameters
NameTypeDescription
$checkProxyboolean
Returns
TypeDescription
string
methodpublicgetControllerKey() : string
inherited

Retrieve the controller key

Inherited from: \Zend_Controller_Request_Abstract::getControllerKey()
Returns
TypeDescription
string
methodpublicgetControllerName() : string
inherited

Retrieve the controller name

Inherited from: \Zend_Controller_Request_Abstract::getControllerName()
Returns
TypeDescription
string
methodpublicgetCookie(string $key = null, mixed $default = null) : mixed

Retrieve a member of the $_COOKIE superglobal

If no $key is passed, returns the entire $_COOKIE array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
Details
Todo
How to retrieve from nested arrays  
methodpublicgetEnv(string $key = null, mixed $default = null) : mixed

Retrieve a member of the $_ENV superglobal

If no $key is passed, returns the entire $_ENV array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
methodpublicgetHeader(string $header) : string | false

Return 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.

Parameters
NameTypeDescription
$headerstring

HTTP header name

Returns
TypeDescription
string | falseHTTP header value, or false if not found
Throws
ExceptionDescription
\Zend_Controller_Request_Exception
methodpublicgetHttpHost() : string

Get 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.

Returns
TypeDescription
string
methodpublicgetMethod() : string

Return the method by which the request was made

Returns
TypeDescription
string
methodpublicgetModuleKey() : string
inherited

Retrieve the module key

Inherited from: \Zend_Controller_Request_Abstract::getModuleKey()
Returns
TypeDescription
string
methodpublicgetModuleName() : string
inherited

Retrieve the module name

Inherited from: \Zend_Controller_Request_Abstract::getModuleName()
Returns
TypeDescription
string
methodpublicgetParam(mixed $key, mixed $default = null) : mixed

Retrieve 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.

Parameters
NameTypeDescription
$keymixed
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixed
methodpublicgetParamSources() : array

Get list of allowed parameter sources

Returns
TypeDescription
array
methodpublicgetParams() : array

Retrieve 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).

Returns
TypeDescription
array
methodpublicgetPathInfo() : string

Returns everything between the BaseUrl and QueryString.

This value is calculated instead of reading PATH_INFO directly from $_SERVER due to cross-platform differences.

Returns
TypeDescription
string
methodpublicgetPost(string $key = null, mixed $default = null) : mixed

Retrieve a member of the $_POST superglobal

If no $key is passed, returns the entire $_POST array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
Details
Todo
How to retrieve from nested arrays  
methodpublicgetQuery(string $key = null, mixed $default = null) : mixed

Retrieve a member of the $_GET superglobal

If no $key is passed, returns the entire $_GET array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
Details
Todo
How to retrieve from nested arrays  
methodpublicgetRawBody() : string | false

Return the raw body of the request, if present

Returns
TypeDescription
string | falseRaw body, or false if not present
methodpublicgetRequestUri() : string

Returns the REQUEST_URI taking into account platform differences between Apache and IIS

Returns
TypeDescription
string
methodpublicgetScheme() : string

Get the request URI scheme

Returns
TypeDescription
string
methodpublicgetServer(string $key = null, mixed $default = null) : mixed

Retrieve a member of the $_SERVER superglobal

If no $key is passed, returns the entire $_SERVER array.

Parameters
NameTypeDescription
$keystring
$defaultmixed

Default value to use if key not found

Returns
TypeDescription
mixedReturns null if key does not exist
methodpublicgetUserParam(string $key, string $default = null) : mixed
inherited

Retrieve a single user param (i.e, a param specific to the object and not the environment)

Inherited from: \Zend_Controller_Request_Abstract::getUserParam()
Parameters
NameTypeDescription
$keystring
$defaultstring

Default value to use if key not found

Returns
TypeDescription
mixed
methodpublicgetUserParams() : array
inherited

Retrieve only user params (i.e, any param specific to the object and not the environment)

Inherited from: \Zend_Controller_Request_Abstract::getUserParams()
Returns
TypeDescription
array
methodpublichas(string $key) : boolean

Alias to __isset()

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
boolean
methodpublicisDelete() : boolean

Was the request made by DELETE?

Returns
TypeDescription
boolean
methodpublicisDispatched() : boolean
inherited

Determine if the request has been dispatched

Inherited from: \Zend_Controller_Request_Abstract::isDispatched()
Returns
TypeDescription
boolean
methodpublicisFlashRequest() : boolean

Is this a Flash request?

Returns
TypeDescription
boolean
methodpublicisGet() : boolean

Was the request made by GET?

Returns
TypeDescription
boolean
methodpublicisHead() : boolean

Was the request made by HEAD?

Returns
TypeDescription
boolean
methodpublicisOptions() : boolean

Was the request made by OPTIONS?

Returns
TypeDescription
boolean
methodpublicisPost() : boolean

Was the request made by POST?

Returns
TypeDescription
boolean
methodpublicisPut() : boolean

Was the request made by PUT?

Returns
TypeDescription
boolean
methodpublicisSecure() : boolean

Is https secure request

Returns
TypeDescription
boolean
methodpublicisXmlHttpRequest() : boolean

Is the request a Javascript XMLHttpRequest?

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

Returns
TypeDescription
boolean
methodpublicset(string $key, mixed $value) : void

Alias to __set()

Parameters
NameTypeDescription
$keystring
$valuemixed
methodpublicsetActionKey(string $key) : \Zend_Controller_Request_Abstract
inherited

Set the action key

Inherited from: \Zend_Controller_Request_Abstract::setActionKey()
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetActionName(string $value) : \Zend_Controller_Request_Abstract
inherited

Set the action name

Inherited from: \Zend_Controller_Request_Abstract::setActionName()
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetAlias(string $name, string $target) : \Zend_Controller_Request_Http

Set a key alias

Set an alias used for key lookups. $name specifies the alias, $target specifies the actual key to use.

Parameters
NameTypeDescription
$namestring
$targetstring
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetBasePath(string | null $basePath = null) : \Zend_Controller_Request_Http

Set the base path for the URL

Parameters
NameTypeDescription
$basePathstring | null
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetBaseUrl(mixed $baseUrl = null) : \Zend_Controller_Request_Http

Set 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.

Parameters
NameTypeDescription
$baseUrlmixed
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetControllerKey(string $key) : \Zend_Controller_Request_Abstract
inherited

Set the controller key

Inherited from: \Zend_Controller_Request_Abstract::setControllerKey()
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetControllerName(string $value) : \Zend_Controller_Request_Abstract
inherited

Set the controller name to use

Inherited from: \Zend_Controller_Request_Abstract::setControllerName()
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetDispatched(boolean $flag = true) : \Zend_Controller_Request_Abstract
inherited

Set flag indicating whether or not request has been dispatched

Inherited from: \Zend_Controller_Request_Abstract::setDispatched()
Parameters
NameTypeDescription
$flagboolean
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetModuleKey(string $key) : \Zend_Controller_Request_Abstract
inherited

Set the module key

Inherited from: \Zend_Controller_Request_Abstract::setModuleKey()
Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetModuleName(string $value) : \Zend_Controller_Request_Abstract
inherited

Set the module name to use

Inherited from: \Zend_Controller_Request_Abstract::setModuleName()
Parameters
NameTypeDescription
$valuestring
Returns
TypeDescription
\Zend_Controller_Request_Abstract
methodpublicsetParam(mixed $key, mixed $value) : \Zend_Controller_Request_Http

Set 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.

Parameters
NameTypeDescription
$keymixed
$valuemixed
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetParamSources( $paramSources = array()) : \Zend_Controller_Request_Http

Set allowed parameter sources

Can be empty array, or contain one or more of '_GET' or '_POST'.

Parameters
NameTypeDescription
$paramSources
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetParams(array $params) : \Zend_Controller_Request_Http

Set parameters

Set one or more parameters. Parameters are set as userland parameters, using the keys specified in the array.

Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetPathInfo(string | null $pathInfo = null) : \Zend_Controller_Request_Http

Set the PATH_INFO string

Parameters
NameTypeDescription
$pathInfostring | null
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetPost(string | array $spec, null | mixed $value = null) : \Zend_Controller_Request_Http

Set POST values

Parameters
NameTypeDescription
$specstring | array
$valuenull | mixed
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetQuery(string | array $spec, null | mixed $value = null) : \Zend_Controller_Request_Http

Set GET values

Parameters
NameTypeDescription
$specstring | array
$valuenull | mixed
Returns
TypeDescription
\Zend_Controller_Request_Http
methodpublicsetRequestUri(string $requestUri = null) : \Zend_Controller_Request_Http

Set 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'].

Parameters
NameTypeDescription
$requestUristring
Returns
TypeDescription
\Zend_Controller_Request_Http
Documentation was generated by phpDocumentor 2.0.0a12.