system/helpers/request.php
Class: request_Core
class request_Core
Request helper class.
Methods
- request_Core :: referrer
- request_Core :: is_ajax
- request_Core :: method
- request_Core :: accepts
- request_Core :: preferred_accept
- request_Core :: accepts_at_quality
- request_Core :: parse_accept_header
request_Core :: referrer
public static function referrer
Returns the HTTP referrer, or the default if the referrer is not set.
Parameters:
- mixed default
- (FALSE) default to return
Return: string
request_Core :: is_ajax
public static function is_ajax
Tests if the current request is an AJAX request by checking the X-Requested-With HTTP request header that most popular JS frameworks now set for AJAX calls.
Return: boolean
request_Core :: method
public static function method
Returns current request method.
Throws: Kohana_Exception in case of an unknown request method
Return: string
request_Core :: accepts
public static function accepts
Returns boolean of whether client accepts content type.
Parameters:
- string type
- (NULL) content type
- boolean explicit_check
- (FALSE) set to TRUE to disable wildcard checking
Return: boolean
request_Core :: preferred_accept
public static function preferred_accept
Compare the q values for given array of content types and return the one with the highest value. If items are found to have the same q value, the first one encountered in the given array wins. If all items in the given array have a q value of 0, FALSE is returned.
Parameters:
- array types
- content types
- boolean explicit_check
- (FALSE) set to TRUE to disable wildcard checking
Return: mixed string mime type with highest q value, FALSE if none of the given types are accepted
request_Core :: accepts_at_quality
public static function accepts_at_quality
Returns quality factor at which the client accepts content type.
Parameters:
- string type
- (NULL) content type (e.g. "image/jpg", "jpg")
- boolean explicit_check
- (FALSE) set to TRUE to disable wildcard checking
Return: integer|float
request_Core :: parse_accept_header
protected static function parse_accept_header
Parses client's HTTP Accept request header, and builds array structure representing it.
Return: void