Elgg  Version 4.3
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Http\Request Class Reference

Elgg HTTP request. More...

Inheritance diagram for Elgg\Http\Request:

Public Member Functions

 __construct (array $query=[], array $request=[], array $attributes=[], array $cookies=[], array $files=[], array $server=[], $content=null)
 {} More...
 
 initializeTrustedProxyConfiguration (Config $config)
 Configure trusted proxy servers to allow access to more client information. More...
 
 initializeContext ()
 Initialize context stack. More...
 
 getContextStack ()
 Returns context stack. More...
 
 setRoute (Route $route)
 Sets the route matched for this request by the router. More...
 
 getRoute ()
 Returns the route matched for this request by the router. More...
 
 setParam (string $key, $value, bool $override_request=false)
 Sets an input value that may later be retrieved by get_input. More...
 
 getParam (string $key, $default=null, bool $filter_result=true)
 Get some input from variables passed submitted through GET or POST. More...
 
 getParams (bool $filter_result=true)
 Returns all values parsed from the request. More...
 
 getCurrentURL ()
 Returns current page URL. More...
 
 getUrlSegments (bool $raw=false)
 Get the Elgg URL segments. More...
 
 setUrlSegments (array $segments)
 Get a cloned request with new Elgg URL segments. More...
 
 getFirstUrlSegment ()
 Get first Elgg URL segment. More...
 
 getElggPath ()
 Get the Request URI minus querystring. More...
 
 getClientIp ()
 {} More...
 
 isXmlHttpRequest ()
 {} More...
 
 sniffElggUrl ()
 Sniff the Elgg site URL with trailing slash. More...
 
 isRewriteCheck ()
 Is the request for checking URL rewriting? More...
 
 isAction ()
 Is the request an action. More...
 
 isCliServer ()
 Is PHP running the CLI server front controller. More...
 
 isCliServable ($root)
 Is the request pointing to a file that the CLI server can handle? More...
 
 getFiles ($input_name)
 Returns an array of uploaded file objects regardless of upload status/errors. More...
 
 getFile ($input_name, $check_for_validity=true)
 Returns the first file found based on the input name. More...
 
 validate ()
 Validate the request. More...
 
 correctBaseURL (\Elgg\Config $config)
 Correct the base URL of the request. More...
 

Public Attributes

const REWRITE_TEST_TOKEN = '__testing_rewrite'
 
const REWRITE_TEST_OUTPUT = 'success'
 

Protected Member Functions

 validateRequestHostHeader ()
 Validate that the request was made on the correct host. More...
 
 validateRequestBodyTruncated ()
 Validate that the request body hasn't been truncated (eg. More...
 

Protected Attributes

 $context_stack
 
 $route
 
 $request_overrides
 
 $filtered_params
 
 $unfiltered_params
 

Detailed Description

Elgg HTTP request.

Definition at line 17 of file Request.php.

Constructor & Destructor Documentation

Elgg\Http\Request::__construct ( array  $query = [],
array  $request = [],
array  $attributes = [],
array  $cookies = [],
array  $files = [],
array  $server = [],
  $content = null 
)

{}

Definition at line 50 of file Request.php.

Member Function Documentation

Elgg\Http\Request::correctBaseURL ( \Elgg\Config  $config)

Correct the base URL of the request.

Parameters
\Elgg\Config$configthe Elgg config
Returns
void
See also
https://github.com/Elgg/Elgg/issues/13667
Since
4.3

Definition at line 536 of file Request.php.

Elgg\Http\Request::getClientIp ( )

{}

Definition at line 294 of file Request.php.

Elgg\Http\Request::getContextStack ( )

Returns context stack.

Returns
Context

Definition at line 102 of file Request.php.

Elgg\Http\Request::getCurrentURL ( )

Returns current page URL.

It uses the configured site URL for the hostname rather than depending on what the server uses to populate $_SERVER.

Returns
string

Definition at line 210 of file Request.php.

Elgg\Http\Request::getElggPath ( )

Get the Request URI minus querystring.

Returns
string

Definition at line 281 of file Request.php.

Elgg\Http\Request::getFile (   $input_name,
  $check_for_validity = true 
)

Returns the first file found based on the input name.

Parameters
string$input_nameForm input name
bool$check_for_validityIf there is an uploaded file, is it required to be valid
Returns
UploadedFile|false

Definition at line 428 of file Request.php.

Elgg\Http\Request::getFiles (   $input_name)

Returns an array of uploaded file objects regardless of upload status/errors.

Parameters
string$input_nameForm input name
Returns
UploadedFile[]

Definition at line 407 of file Request.php.

Elgg\Http\Request::getFirstUrlSegment ( )

Get first Elgg URL segment.

See also
::getUrlSegments()
Returns
string

Definition at line 267 of file Request.php.

Elgg\Http\Request::getParam ( string  $key,
  $default = null,
bool  $filter_result = true 
)

Get some input from variables passed submitted through GET or POST.

If using any data obtained from get_input() in a web page, please be aware that it is a possible vector for a reflected XSS attack. If you are expecting an integer, cast it to an int. If it is a string, escape quotes.

Parameters
string$keyThe variable name we want.
mixed$defaultA default value for the variable if it is not found.
bool$filter_resultIf true, then the result is filtered for bad tags.
Returns
mixed

Definition at line 169 of file Request.php.

Elgg\Http\Request::getParams ( bool  $filter_result = true)

Returns all values parsed from the request.

Parameters
bool$filter_resultSanitize input values
Returns
array

Definition at line 182 of file Request.php.

Elgg\Http\Request::getRoute ( )

Returns the route matched for this request by the router.

Returns
Route|null

Definition at line 127 of file Request.php.

Elgg\Http\Request::getUrlSegments ( bool  $raw = false)

Get the Elgg URL segments.

Parameters
bool$rawIf true, the segments will not be HTML escaped
Returns
string[]

Definition at line 233 of file Request.php.

Elgg\Http\Request::initializeContext ( )

Initialize context stack.

Returns
static

Definition at line 90 of file Request.php.

Elgg\Http\Request::initializeTrustedProxyConfiguration ( Config  $config)

Configure trusted proxy servers to allow access to more client information.

Returns
void

Definition at line 71 of file Request.php.

Elgg\Http\Request::isAction ( )

Is the request an action.

Returns
bool
Since
4.1

Definition at line 360 of file Request.php.

Elgg\Http\Request::isCliServable (   $root)

Is the request pointing to a file that the CLI server can handle?

Parameters
string$rootRoot directory
Returns
bool

Definition at line 380 of file Request.php.

Elgg\Http\Request::isCliServer ( )

Is PHP running the CLI server front controller.

Returns
bool

Definition at line 369 of file Request.php.

Elgg\Http\Request::isRewriteCheck ( )

Is the request for checking URL rewriting?

Returns
bool

Definition at line 342 of file Request.php.

Elgg\Http\Request::isXmlHttpRequest ( )

{}

Definition at line 313 of file Request.php.

Elgg\Http\Request::setParam ( string  $key,
  $value,
bool  $override_request = false 
)

Sets an input value that may later be retrieved by get_input.

Note: this function does not handle nested arrays (ex: form input of param[m][n])

Parameters
string$keyThe name of the variable
mixed$valueThe value of the variable
bool$override_requestThe variable should override request values (default: false)
Returns
static

Definition at line 142 of file Request.php.

Elgg\Http\Request::setRoute ( Route  $route)

Sets the route matched for this request by the router.

Parameters
Route$routeRoute
Returns
static

Definition at line 113 of file Request.php.

Elgg\Http\Request::setUrlSegments ( array  $segments)

Get a cloned request with new Elgg URL segments.

Parameters
string[]$segments URL segments
Returns
Request

Definition at line 252 of file Request.php.

Elgg\Http\Request::sniffElggUrl ( )

Sniff the Elgg site URL with trailing slash.

Returns
string

Definition at line 324 of file Request.php.

Elgg\Http\Request::validate ( )

Validate the request.

Returns
void
Exceptions
BadRequestException

Definition at line 452 of file Request.php.

Elgg\Http\Request::validateRequestBodyTruncated ( )
protected

Validate that the request body hasn't been truncated (eg.

exceeded POST max size)

Returns
void
Exceptions
BadRequestException
Since
3.0

Definition at line 487 of file Request.php.

Elgg\Http\Request::validateRequestHostHeader ( )
protected

Validate that the request was made on the correct host.

This will prevent malicious requests from being processed

Returns
void
Exceptions
BadRequestException
Since
3.3.25

Definition at line 466 of file Request.php.

Member Data Documentation

Elgg\Http\Request::$context_stack
protected

Definition at line 25 of file Request.php.

Elgg\Http\Request::$filtered_params
protected

Definition at line 40 of file Request.php.

Elgg\Http\Request::$request_overrides
protected

Definition at line 35 of file Request.php.

Elgg\Http\Request::$route
protected

Definition at line 30 of file Request.php.

Elgg\Http\Request::$unfiltered_params
protected

Definition at line 45 of file Request.php.

const Elgg\Http\Request::REWRITE_TEST_OUTPUT = 'success'

Definition at line 20 of file Request.php.

const Elgg\Http\Request::REWRITE_TEST_TOKEN = '__testing_rewrite'

Definition at line 19 of file Request.php.


The documentation for this class was generated from the following file: