abstract class RequestInformationHelper (View source)

Helper to extract various information from PSR-7 requests.

Methods

static string
getScriptRequestPathAndFilename(ServerRequestInterface $request)

Returns the relative path (i.e. relative to the web root) and name of the script as it was accessed through the web server.

static string
getScriptRequestPath(ServerRequestInterface $request)

Returns the relative path (i.e. relative to the web root) to the script as it was accessed through the web server.

static string
getRelativeRequestPath(ServerRequestInterface $request)

Constructs a relative path for this request, that is the path segments left after removing the baseUri.

static UriInterface
generateBaseUri(ServerRequestInterface $request)

Tries to detect the base URI of request.

static string
generateRequestLine(RequestInterface $request)

Return the Request-Line of this Request Message, consisting of the method, the URI and the HTTP version Would be, for example, "GET /foo?bar=baz HTTP/1.1" Note that the URI part is, at the moment, only possible in the form "abs_path" since the actual requestUri of the Request cannot be determined during the creation of the Request.

static string
renderRequestInformation(RequestInterface $request)

Renders information about the request

static string
renderRequestHeaders(RequestInterface $request)

Renders the HTTP headers - EXCLUDING the status header - of the given request

static string
getContentCharset(RequestInterface $request)

Extract the charset from the content type header if available

static array
extractHeadersFromServerVariables(array $server)

Extract header key/value pairs from a $_SERVER array.

Details

static string getScriptRequestPathAndFilename(ServerRequestInterface $request)

Returns the relative path (i.e. relative to the web root) and name of the script as it was accessed through the web server.

Parameters

ServerRequestInterface $request

The request in question

Return Value

string

Relative path and name of the PHP script as accessed through the web

static string getScriptRequestPath(ServerRequestInterface $request)

Returns the relative path (i.e. relative to the web root) to the script as it was accessed through the web server.

Parameters

ServerRequestInterface $request

The request in question

Return Value

string

Relative path to the PHP script as accessed through the web

static string getRelativeRequestPath(ServerRequestInterface $request)

Constructs a relative path for this request, that is the path segments left after removing the baseUri.

Parameters

ServerRequestInterface $request

Return Value

string

static UriInterface generateBaseUri(ServerRequestInterface $request)

Tries to detect the base URI of request.

Parameters

ServerRequestInterface $request

Return Value

UriInterface

static string generateRequestLine(RequestInterface $request)

Return the Request-Line of this Request Message, consisting of the method, the URI and the HTTP version Would be, for example, "GET /foo?bar=baz HTTP/1.1" Note that the URI part is, at the moment, only possible in the form "abs_path" since the actual requestUri of the Request cannot be determined during the creation of the Request.

Parameters

RequestInterface $request

Return Value

string

See also

http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1

static string renderRequestInformation(RequestInterface $request)

Renders information about the request

Parameters

RequestInterface $request

Return Value

string

static string renderRequestHeaders(RequestInterface $request)

Renders the HTTP headers - EXCLUDING the status header - of the given request

Parameters

RequestInterface $request

Return Value

string

static string getContentCharset(RequestInterface $request)

Extract the charset from the content type header if available

Parameters

RequestInterface $request

Return Value

string

the found charset or empty string if none

static array extractHeadersFromServerVariables(array $server)

Extract header key/value pairs from a $_SERVER array.

Parameters

array $server

Return Value

array