Overview

Namespaces

  • Alpha
    • Controller
      • Front
    • Exception
    • Model
      • Type
    • Task
    • Util
      • Backup
      • Cache
      • Code
        • Highlight
        • Metric
      • Config
      • Convertor
      • Email
      • Extension
      • Feed
      • File
      • Graph
      • Helper
      • Http
        • Filter
        • Session
      • Image
      • Logging
      • Search
      • Security
    • View
      • Renderer
        • Html
        • Json
      • Widget

Classes

  • AgentUtils
  • PHPServerUtils
  • Request
  • Response
  • Overview
  • Namespace
  • Class
  • Tree

Class Request

A class to encapsulate a HTTP request.

Namespace: Alpha\Util\Http
Copyright: Copyright (c) 2015, John Collins (founder of Alpha Framework). All rights reserved. <pre> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Alpha Framework nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. </pre>
License: The BSD License
Author: John Collins <dev@alphaframework.org>
Since: 2.0
Located at Util/Http/Request.php
Methods summary
public
# __construct( array $overrides = array() )

Builds up the request based on available PHP super globals, in addition to any overrides provided (useful for testing).

Builds up the request based on available PHP super globals, in addition to any overrides provided (useful for testing).

Parameters

$overrides
array $overrides Hash array of PHP super globals to override

Throws

Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

Since

2.0
public string
# getMethod( )

Get the HTTP method of this request.

Get the HTTP method of this request.

Returns

string
string

Since

2.0
public
# setMethod( string $method )

Set the HTTP method of this request.

Set the HTTP method of this request.

Parameters

$method
string $method

Throws

Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

Since

2.0
public array
# getHeaders( )

Return all headers on this request.

Return all headers on this request.

Returns

array
array

Since

2.0
public mixed
# getHeader( string $key, mixed $default = null )

Get the header matching the key provided.

Get the header matching the key provided.

Parameters

$key
string $key The key to search for
$default
mixed $default If key is not found, return this instead

Returns

mixed
mixed

Since

2.0
public array
# getCookies( )

Return all cookies on this request.

Return all cookies on this request.

Returns

array
array

Since

2.0
public mixed
# getCookie( string $key, mixed $default = null )

Get the cookie matching the key provided.

Get the cookie matching the key provided.

Parameters

$key
string $key The key to search for
$default
mixed $default If key is not found, return this instead

Returns

mixed
mixed

Since

2.0
public array
# getParams( )

Return all params on this request.

Return all params on this request.

Returns

array
array

Since

2.0
public mixed
# getParam( string $key, mixed $default = null )

Get the param matching the key provided.

Get the param matching the key provided.

Parameters

$key
string $key The key to search for
$default
mixed $default If key is not found, return this instead

Returns

mixed
mixed

Since

2.0
public
# addParams( array $params )

Append the hash array provided to the params for this request.

Append the hash array provided to the params for this request.

Parameters

$params
array A hash array of values to add to the request params

Since

2.0
public
# setParams( array $params )

Set the params array.

Set the params array.

Parameters

$params
array A hash array of values to set as the request params

Since

2.0
public array
# getFiles( )

Return all files on this request.

Return all files on this request.

Returns

array
array

Since

2.0
public mixed
# getFile( string $key, mixed $default = null )

Get the file matching the key provided.

Get the file matching the key provided.

Parameters

$key
string $key The key to search for
$default
mixed $default If key is not found, return this instead

Returns

mixed
mixed

Since

2.0
public string
# getBody( )

Get the request body if one was provided.

Get the request body if one was provided.

Returns

string
string

Since

2.0
public string
# getAccept( )

Get the Accept header of the request.

Get the Accept header of the request.

Returns

string
string

Since

2.0
public string
# getContentType( )

Get the Content-Type header of the request.

Get the Content-Type header of the request.

Returns

string
string

Since

2.0
public string
# getContentLength( )

Get the Content-Length header of the request.

Get the Content-Length header of the request.

Returns

string
string

Since

2.0
public string
# getHost( )

Get the host name of the client that sent the request.

Get the host name of the client that sent the request.

Returns

string
string

Since

2.0
public string
# getURI( )

Get the URI that was requested.

Get the URI that was requested.

Returns

string
string

Since

2.0
public string
# getURL( )

Get the URL that was requested.

Get the URL that was requested.

Returns

string
string

Since

2.0
public string
# getIP( )

Get the IP address of the client that sent the request.

Get the IP address of the client that sent the request.

Returns

string
string

Since

2.0
public string
# getReferrer( )

Get the Referrer header of the request.

Get the Referrer header of the request.

Returns

string
string

Since

2.0
public string
# getUserAgent( )

Get the User-Agent header of the request.

Get the User-Agent header of the request.

Returns

string
string

Since

2.0
public string
# getQueryString( )

Get the query string provided on the request.

Get the query string provided on the request.

Returns

string
string

Since

2.0
public
# parseParamsFromRoute( string $route, array $defaultParams = array() )

Parses the route provided to extract matching params of the route from this request's URI.

Parses the route provided to extract matching params of the route from this request's URI.

Parameters

$route
string $route The route with parameter names, e.g. /user/{username}
$defaultParams
array $defaultParams Optional hash array of default request param values to use if they are missing from URI

Since

2.0
public boolean
# isSecureURI( )

Checks to see if the request contains a secure/encrypted token.

Checks to see if the request contains a secure/encrypted token.

Returns

boolean
bool

Since

2.0
Alpha Framework 2.0.4 API Documentation API documentation generated by ApiGen 2.8.0