Class HttpRequest (namespace Nette\Web)


HttpRequest provides access scheme for request sent via HTTP.

Object
   |
   --HttpRequest

Implements interfaces:

Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Web/HttpRequest.php (line 36)
Public 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.
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.
Protected Method Summary
protected void
Detects uri, base path and script path of the request.
Methods Inherited From Object
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Variable Summary
protected array $cookies

line 48

protected string $encoding

line 66

protected array $files

line 45

protected array $headers

line 57

HttpRequest::getHeaders()
protected Uri $originalUri

line 54

HttpRequest::getOriginalUri()
protected array $post

line 42

protected array $query

line 39

protected UriScript $uri

line 51

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

line 60


Method Details

line 111

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 141

detectUri

protected void detectUri ()

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

Output
void  

line 365

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 388

getCookies

public array getCookies ()

Returns variables provided to the script via HTTP cookies.

Implementation of:

Output
array  

line 325

getFile

public HttpUploadedFile getFile (string $key)

Returns uploaded file.

Implementation of:

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

line 348

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 94

getOriginalUri

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

Returns URL object.

Input
bool $clone
Output
Uri  

line 290

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 313

getPostRaw

public string getPostRaw ()

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

Implementation of:

Output
string  

line 264

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 79

getUri

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

Returns URL object.

Implementation of:

Input
bool $clone
Output
UriScript  

line 130

getUriFilters

public array getUriFilters ()

Returns request URI filter.

Output
array  

line 419

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 405

setEncoding

public void setEncoding (array $encoding, string 1)

Recursively converts and checks encoding.

Input
array $encoding
string 1
Output
void