Class Ismo_Core_Request

Description

This class represents one HTTP request.

It's modelled quite much after Java's ServletAPI. So if you've used Java you will feel at home.

Located in /Request.php (line 38)


	
			
Variable Summary
Method Summary
Ismo_Core_Request Ismo_Core_Request ()
integer getContentLength ()
string getContentType ()
string getContextPath ()
array &getCookies ()
string getDefaultLocale ()
string getHeader (string $name)
array getHeaderNames ()
array getHeaders ()
string getIP ()
string getLocale ()
string getMethod ()
mixed getParameter (string $name, string $type)
array &getParameterArray ([string $type = 'GET'])
array getParameterNames ([string $type = 'GET'])
mixed getPathParameter (string $name)
mixed getPathParameterAt (number $index)
string getProtocol ()
string getQueryString ()
string getRemoteAddress ()
string getRemoteHost ()
string getServerName ()
string getServerPort ()
bool isPathParameterSet (string $name)
boolean isSecure ()
void setDefaultLocale (string $locale)
void setSupportedLocales (array $locales)
array _getAllHeaders ()
void _getAllHeadersHelper (mixed $value, mixed $key, mixed &$result)
Variables
string $_defaultLocale = 'en-us' (line 77)

The default locale (eg. en-us) the application uses.

  • access: private
array $_headers = NULL (line 47)

All the headers.

  • access: private
array $_pathParameters = NULL (line 57)

The context path parameters in an indexed array.

  • access: private
array $_pathParametersAssoc = NULL (line 67)

The context path parameters in an associative array.

  • access: private
array $_supportedLocales = NULL (line 88)

The locales (eg. en-us, fi_fi, se_se etc) the application supports.

  • access: private
Methods
Constructor Ismo_Core_Request (line 157)

The constructor.

  • access: public
Ismo_Core_Request Ismo_Core_Request ()
getCharacterEncoding (line 328)

Gets the used character encoding.

Returns the name of the character encoding used in the body of this request.

  • return: the used character encoding
  • access: public
  • todo: implement this method
string getCharacterEncoding ()
getContentLength (line 345)

Gets the content length.

Returns the length, in bytes, of the request body or -1 if the length is not known.

  • return: the content length
  • access: public
  • todo: implement this method
integer getContentLength ()
getContentType (line 362)

Gets the content type.

Returns the MIME type of the body of the request or NULL if the type is not known.

  • return: the content type NULL if it's not known
  • access: public
  • todo: implement this method
string getContentType ()
getContextPath (line 179)

Returns the context path.

Returns the portion of the request URI that indicates the context of the request.

Example

  1. // if the request is done to http://foo/bar.php/name/value
  2. $contextPath = $this->getContextPath();

  • return: the context path or null if there is none
  • access: public
string getContextPath ()
getCookies (line 196)

Gets the available cookies.

Returns an associative array containing all of the cookies objects the client sent with this request.

  • return: the cookies
  • access: public
  • todo: to be or not to be?
array &getCookies ()
getDefaultLocale (line 375)

Gets the default locale for the application.

  • return: the default locale
  • access: public
string getDefaultLocale ()
getHeader (line 212)

Gets the value of header.

Returns the value of the specified request header.

  • return: the value of the specified header
  • access: public
string getHeader (string $name)
  • string $name: the name of the header
getHeaderNames (line 235)

Gets all the header names.

Returns an array of all the header names this request contains.

  • return: all the available headers as strings
  • access: public
array getHeaderNames ()
getHeaders (line 254)

Gets all the headers.

Returns an associative array of all the header names and values of this request.

  • return: containing all the headers
  • access: public
array getHeaders ()
getIP (line 274)

Gets the ip address.

Returns the Internet Protocol (IP) address of the client that sent the request. Different from getRemoteAddress, also checks for HTTP_CLIENT_IP and HTTP_X_FORWARD_FOR

  • return: the ip address
  • access: public
string getIP ()
getLocale (line 407)

Deduces the clients preferred locale.

You might want to override this method if you want to do more sophisticated decisions. It gets the supported locales and the default locale from the class attributes file and tries to find a match. If no match is found it uses the default locale. The locale is always changed into lowercase.

  • return: the locale
  • access: public
string getLocale ()
getMethod (line 295)

Gets the request method.

Returns the name of the HTTP method with which this request was made., for example, GET, POST, or PUT.

  • return: the method
  • access: public
string getMethod ()
getParameter (line 458)

Returns the parameter from the request parameters if it's available.

Parameters can come from different sources. Get parameters are the result of a HTTP GET operation, post parameters are the result of a HTTP POST operation, cookie parameters are the parameters given by the cookies stored in the client browser for this domain and request parameters are a combination of all the earlier types combined according to the variables_order configuration directive.

One has to choose what type of parameter to get with the second parameter to this method.

  • GET - get the parameter from the GET parameters
  • POST - get the parameter from the POST parameters
  • COOKIE - get the parameters from the COOKIE parameters
  • REQUEST - get the parameters from the REQUEST parameters

Note that the returned value can be an array if the parameter has multiple values.

  • return: the value as a string if it's a single value, an array containing the values as strings if there are more than one value or null if a parameter with the specified name doesn't exist
  • access: public
mixed getParameter (string $name, string $type)
  • string $name: the name of the parameter
  • string $type: the type, COOKIE|GET|REQUEST|POST
getParameterArray (line 612)

Returns an array containing the name-value pair of the parameters.

It defauls to returning an array for the GET parameters if nothing else is specified.

  • return: it's an empty array if there are no parameters
  • access: public
  • todo: to be or not to be? maybe changed like getParameter?
array &getParameterArray ([string $type = 'GET'])
  • string $type: the type, GET|POST defaults to GET
getParameterNames (line 643)

Returns the names of the available parameters.

This returns an array containing the names of the available parameters. It defauls to returning an array for the GET parameters if nothing else is specified.

  • return: the array, it's an empty array if there are no parameters
  • access: public
  • todo: changed like getParameter()
array getParameterNames ([string $type = 'GET'])
  • string $type: the type, GET|POST defaults to GET
getPathParameter (line 503)

Returns the path info parameter from the request.

This returns the next value after the first occurrence of $name in the path info string for this request.

Example:

  1. // the url is http://foo/bar.php/name1/value1/name2/value2
  2. $v = $this->request->getPathParameter('name1');

Everything after bar.php above is treated as path info parameters and a search from the beginning to the end is made and the value after the first match is returned.

  • return: the value if found otherwise null
  • access: public
mixed getPathParameter (string $name)
  • string $name: the name of the parameter
getPathParameterAt (line 549)

Returns the path info parameter from the request at the specified position.

Returns the value at the given position in the path info or null if no such parameter exists. The first parameter is at position 0, the second one at position 1 etc.

Example:

  1. // the url is http://foo/bar.php/name1/value1/name2/value2
  2. $v = $this->request->getPathParameterAt(0);
  3. // $v is now 'name1'
  4. $v = $this->request->getPathParameterAt(3);

Everything after bar.php above is treated as path info parameters and a search from the beginning to the end is made and the value after the first match is returned.

  • return: the value if found otherwise null
  • access: public
mixed getPathParameterAt (number $index)
  • number $index: the index of the parameter to get
getPathParametersArray (line 563)

Returns the path info parameters from the request in an indexed array.

  • return: the path info parameters in an indexed array.
  • access: public
array getPathParametersArray ()
getPathParametersAssoc (line 580)

Returns the path info parameters from the request in an associative array.

  • return: the path info parameters in an associative array
  • access: public
array getPathParametersAssoc ()
getProtocol (line 670)

Gets the protocol.

Returns the name and version of the protocol the request uses in the form protocol/majorVersion/minorVersion, for example HTTP/1.1

  • return: the protocol name
  • access: public
string getProtocol ()
getQueryString (line 311)

Gets the query string.

Returns the query string this is contained in the request URL after the path.

  • return: the query string
  • access: public
string getQueryString ()
getRemoteAddress (line 686)

Gets the remove address.

Returns the Internet Protocol (IP) address of the client that sent the request.

  • return: the ip address
  • access: public
string getRemoteAddress ()
getRemoteHost (line 706)

Gets the remove host.

Returns the fully qualified name of the client that sent the request.

This is figured out by doing a dns server lookup of the ip address. If no host is associated with the address NULL is returned.

  • return: the remote client's hostname or NULL if it can't be resolved.
  • access: public
string getRemoteHost ()
getServerName (line 726)

Gets the server name.

Returns the host name of the server that received the request.

  • return: the host name
  • access: public
string getServerName ()
getServerPort (line 741)

Gets the port number.

Returns the port number on which this request was received.

  • return: the port number
  • access: public
string getServerPort ()
getSupportedLocales (line 388)

Gets the supported locales for the application.

  • return: the supported locales
  • access: public
array getSupportedLocales ()
isPathParameterSet (line 758)

Checks if a path parameter is set.

This tests if a variable named $name is set in the path info string for this request.

  • return: true if found otherwise false
  • access: public
bool isPathParameterSet (string $name)
  • string $name: the name of the parameter
isSecure (line 775)

Indicates wheather the current request is secure or not.

Returns a boolean indication wheather this request was made using a secute channel, such as HTTPS.

  • return: true if secure false otherwise
  • access: public
boolean isSecure ()
setDefaultLocale (line 793)

Sets the default locale for the application.

Create an instance of

  1. Ismo_Core_Request
manually and set the default locale with this method. Then add it as the application's request class with
  1. Ismo_Core_Application::setRequest()
.

  • access: public
void setDefaultLocale (string $locale)
  • string $locale: the default locale
setSupportedLocales (line 811)

Sets the locales supported by the application.

Create an instance of

  1. Ismo_Core_Request
manually and set the supported locales with this method. Then add it as the application's request class with
  1. Ismo_Core_Application::setRequest()
.

  • access: public
void setSupportedLocales (array $locales)
  • array $locales: the locales
_getAllHeaders (line 101)

Returns all HTTP_* headers.

Returns all the HTTP_* headers. Works both if PHP is an apache module and if it's running as a CGI.

  • return: the headers' names and values
  • access: private
array _getAllHeaders ()
_getAllHeadersHelper (line 142)

Helper function for my_getallheaders.

For use with array_walk.

  • access: private
void _getAllHeadersHelper (mixed $value, mixed $key, mixed &$result)

Documentation generated on Mon, 14 Jun 2004 11:59:32 +0200 by phpDocumentor 1.3.0RC3