Class HttpRequest (namespace Nette\Web)


HttpRequest provides access scheme for request sent via HTTP.

Object
   |
   --HttpRequest

Implements interfaces:

IHttpRequest
Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Web/HttpRequest.php (line 38)
Method Summary
void
addUriFilter (string $pattern, [string $replacement = ''], [int $component = NULL])
Sets request URI filter.
string
detectLanguage ($langs)
Parse Accept-Language header and returns prefered language.
protected void
Detects uri, base path and script path of the request.
mixed
getCookie (string $key, [mixed $default = NULL])
Returns variable provided to the script via HTTP cookies.
array
Returns variables provided to the script via HTTP cookies.
HttpUploadedFile
getFile (string $key)
Returns uploaded file.
array
Returns uploaded files.
mixed
getHeader (string $header, [mixed $default = NULL])
Return the value of the HTTP header. Pass the header name as the plain, HTTP-specified header name (e.g. 'Accept-Encoding').
array
Returns all HTTP headers.
string
Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.
Uri
getOriginalUri ([bool $clone = TRUE])
Returns URL object.
mixed
getPost ([string $key = NULL], [mixed $default = NULL])
Returns variable provided to the script via POST method ($_POST).
string
Returns HTTP POST data in raw format (only for "application/x-www-form-urlencoded").
mixed
getQuery ([string $key = NULL], [mixed $default = NULL])
Returns variable provided to the script via URL query ($_GET).
Uri|NULL
Returns referrer.
string
Returns the IP address of the remote client.
string
Returns the host of the remote client.
UriScript
getUri ([bool $clone = TRUE])
Returns URL object.
array
Returns request URI filter.
void
Initializes $this->query, $this->files, $this->cookies and $this->files arrays
bool
isAjax ()
Is AJAX request?
bool
isMethod (string $method)
Checks if the request method is the given one.
bool
isPost ()
Checks if the request method is POST.
bool
Is the request is sent via secure channel (https).
void
setEncoding (array $encoding, string 1)
Recursively converts and checks encoding.
Methods Inherited From Object
Object::extensionMethod(), Object::getClass(), Object::getReflection(), Object::__call(), Object::__callStatic(), Object::__get(), Object::__isset(), Object::__set(), Object::__unset()
Variable Summary
protected array $cookies

line 50

protected string $encoding

line 68

protected array $files

line 47

protected array $headers

line 59

HttpRequest::getHeaders()
protected Uri $originalUri

line 56

HttpRequest::getOriginalUri()
protected array $post

line 44

protected array $query

line 41

protected UriScript $uri

line 53

HttpRequest::getUri()
protected array $uriFilter array( PHP_URL_PATH => array('#/{2,}#' => '/'),// '%20' => '' 0=>array(),//...

line 62


Method Details

line 113

addUriFilter

public void addUriFilter (string $pattern, [string $replacement = ''], [int $component = NULL])

Sets request URI filter.

Input
string $pattern pattern to search for
string $replacement string to replace
int $component PHP_URL_PATH or NULL
Output
void  

line 675

detectLanguage

public string detectLanguage ($langs)

Parse Accept-Language header and returns prefered language.

Input
$langs Supported languages
Output
string  

line 143

detectUri

protected void detectUri ()

Detects uri, base path and script path of the request.

Output
void  

line 367

getCookie

public mixed getCookie (string $key, [mixed $default = NULL])

Returns variable provided to the script via HTTP cookies.

Implementation of:

Input
string $key key
mixed $default default value
Output
mixed  

line 390

getCookies

public array getCookies ()

Returns variables provided to the script via HTTP cookies.

Implementation of:

Output
array  

line 327

getFile

public HttpUploadedFile getFile (string $key)

Returns uploaded file.

Implementation of:

Input
string $key key (or more keys)
Output
HttpUploadedFile  

line 350

getFiles

public array getFiles ()

Returns uploaded files.

Implementation of:

Output
array  

line 570

getHeader

public mixed getHeader (string $header, [mixed $default = NULL])

Return the value of the HTTP header. Pass the header name as the plain, HTTP-specified header name (e.g. 'Accept-Encoding').

Implementation of:

Input
string $header
mixed $default
Output
mixed  

line 587

getHeaders

public array getHeaders ()

Returns all HTTP headers.

Implementation of:

Output
array  

line 533

getMethod

public string getMethod ()

Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.

Implementation of:

Output
string  

line 96

getOriginalUri

public Uri getOriginalUri ([bool $clone = TRUE])

Returns URL object.

Input
bool $clone
Output
Uri  

line 292

getPost

public mixed getPost ([string $key = NULL], [mixed $default = NULL])

Returns variable provided to the script via POST method ($_POST).

If no key is passed, returns the entire array.

Implementation of:

Input
string $key key
mixed $default default value
Output
mixed  

line 315

getPostRaw

public string getPostRaw ()

Returns HTTP POST data in raw format (only for "application/x-www-form-urlencoded").

Implementation of:

Output
string  

line 266

getQuery

public mixed getQuery ([string $key = NULL], [mixed $default = NULL])

Returns variable provided to the script via URL query ($_GET).

If no key is passed, returns the entire array.

Implementation of:

Input
string $key key
mixed $default default value
Output
mixed  

line 611

getReferer

public Uri|NULL getReferer ()

Returns referrer.

Output
Uri|NULL  

line 645

getRemoteAddress

public string getRemoteAddress ()

Returns the IP address of the remote client.

Output
string  

line 656

getRemoteHost

public string getRemoteHost ()

Returns the host of the remote client.

Implementation of:

Output
string  

line 81

getUri

public UriScript getUri ([bool $clone = TRUE])

Returns URL object.

Implementation of:

Input
bool $clone
Output
UriScript  

line 132

getUriFilters

public array getUriFilters ()

Returns request URI filter.

Output
array  

line 421

initialize

public void initialize ()

Initializes $this->query, $this->files, $this->cookies and $this->files arrays

Output
void  

line 634

isAjax

public bool isAjax ()

Is AJAX request?

Implementation of:

Output
bool  

line 545

isMethod

public bool isMethod (string $method)

Checks if the request method is the given one.

Implementation of:

Input
string $method
Output
bool  

line 556

isPost

public bool isPost ()

Checks if the request method is POST.

Output
bool  

line 623

isSecured

public bool isSecured ()

Is the request is sent via secure channel (https).

Implementation of:

Output
bool  

line 407

setEncoding

public void setEncoding (array $encoding, string 1)

Recursively converts and checks encoding.

Input
array $encoding
string 1
Output
void