Elgg  Version 5.1
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 (string $input_name)
 Returns an array of uploaded file objects regardless of upload status/errors. More...
 
 getFile (string $input_name, bool $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'
 
bool $_integration_testing = false
 

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 56 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 543 of file Request.php.

Elgg\Http\Request::getClientIp ( )

{}

Definition at line 303 of file Request.php.

Elgg\Http\Request::getContextStack ( )

Returns context stack.

Returns
Context

Definition at line 110 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 218 of file Request.php.

Elgg\Http\Request::getElggPath ( )

Get the Request URI minus querystring.

Returns
string

Definition at line 290 of file Request.php.

Elgg\Http\Request::getFile ( string  $input_name,
bool  $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|null

Definition at line 440 of file Request.php.

Elgg\Http\Request::getFiles ( string  $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 419 of file Request.php.

Elgg\Http\Request::getFirstUrlSegment ( )

Get first Elgg URL segment.

See also
::getUrlSegments()
Returns
string

Definition at line 276 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 177 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 190 of file Request.php.

Elgg\Http\Request::getRoute ( )

Returns the route matched for this request by the router.

Returns
Route|null

Definition at line 135 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 241 of file Request.php.

Elgg\Http\Request::initializeContext ( )

Initialize context stack.

Returns
static

Definition at line 98 of file Request.php.

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

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

Parameters
Config$configElgg config to read trusted proxy configuration from
Returns
void

Definition at line 79 of file Request.php.

Elgg\Http\Request::isAction ( )

Is the request an action.

Returns
bool
Since
4.1

Definition at line 369 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 389 of file Request.php.

Elgg\Http\Request::isCliServer ( )

Is PHP running the CLI server front controller.

Returns
bool

Definition at line 378 of file Request.php.

Elgg\Http\Request::isRewriteCheck ( )

Is the request for checking URL rewriting?

Returns
bool

Definition at line 351 of file Request.php.

Elgg\Http\Request::isXmlHttpRequest ( )

{}

Definition at line 322 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 150 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 121 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 261 of file Request.php.

Elgg\Http\Request::sniffElggUrl ( )

Sniff the Elgg site URL with trailing slash.

Returns
string

Definition at line 333 of file Request.php.

Elgg\Http\Request::validate ( )

Validate the request.

Returns
void
Exceptions
BadRequestException

Definition at line 464 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 499 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 478 of file Request.php.

Member Data Documentation

bool Elgg\Http\Request::$_integration_testing = false

Definition at line 26 of file Request.php.

Elgg\Http\Request::$context_stack
protected

Definition at line 31 of file Request.php.

Elgg\Http\Request::$filtered_params
protected

Definition at line 46 of file Request.php.

Elgg\Http\Request::$request_overrides
protected

Definition at line 41 of file Request.php.

Elgg\Http\Request::$route
protected

Definition at line 36 of file Request.php.

Elgg\Http\Request::$unfiltered_params
protected

Definition at line 51 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: