Pancake\HTTPRequest API

pp3345 edited this page Apr 3, 2013 · 4 revisions

This is a documentation of APIs available in the Pancake\HTTPRequest class. Instances of Pancake\HTTPRequest are available via $requestObject in custom directory and exception page handlers and via Pancake\vars::$Pancake_request in the PHP SAPI.

Public properties

Basically all those properties are available for read and write. However, writing makes only sense in a few cases. The PHP SAPI will only return the properties answerBody, answerHeaders and answerCode.

string answerBody

The currently saved answer body of the request.

string queryString

The query string of the request, e. g. the string behind the ? in the URL.

array requestHeaders

An array of headers sent in the request.

array answerHeaders

An array of headers that Pancake will send to the client.

string protocolVersion

HTTP version used for the request. Pancake currently supports HTTP 1.0 and 1.1.

string localIP

The local (server) IPv6 or IPv4 address on which the request was received. Please note that IPv4 addresses might be given in IPv6 notation in some cases.

string remoteIP

The IPv4 or IPv6 address of the client.

long localPort

The local TCP port on which the request was received.

long remotePort

The remote TCP port of the client.

string requestLine

The first line of the request. Contains request method, path and HTTP version.

string requestType

The HTTP method used in the request. Pancake currently supports GET, POST, HEAD, TRACE and OPTIONS.

string originalRequestURI

Request path as sent by the client.

string requestURI

Request path after rewrite rules and HTTP parsing has been applied.

string requestFilePath

Full hard disk path to the served file.

string mimeType

MIME type of the requested file.

long requestTime

UNIX timestamp of when the HTTP request was parsed.

float requestMicrotime

UNIX timestamp of when the HTTP request was parsed with microsecond precision.

long answerCode

HTTP answer code that Pancake will send when the request is finished.

array GETParameters

Parsed GET parameters of the request. Please note that this property is only filled when either the JIT parser has been invoked before or JIT parsing is disabled.

array POSTParameters

Parsed POST parameters of the request. Please note that this property is only filled when either the JIT parser has been invoked before or JIT parsing is disabled.

array cookies

Parsed HTTP cookies of the request. Please note that this property is only filled when either the JIT parser has been invoked before or JIT parsing is disabled.

array uploadedFiles

File uploads sent in the request. This array is structured like the PHP $_FILES array. Please note that this property is only filled when either the JIT parser has been invoked before or JIT parsing is disabled.

long rangeFrom

Begin of requested byte range.

long rangeTo

End of requested byte range.

string pathInfo

CGI path info data as specified by rewrite rules.

boolean TLS

A boolean that indicates whether the request was sent via an encrypted connection or not.


Public methods

void setHeader(string $name, mixed $value[, boolean $replace = 1])

This method can be used to set an HTTP answer header.

static string getAnswerCodeString(long $answerCode)

This method returns the string corresponding to an HTTP answer code.

array getGETParams()

This method returns the GET parameters sent in an HTTP request. If the parameters are not yet parsed, the parser will be invoked.

array getPOSTParams()

This method returns the POST parameters sent in an HTTP request. If the parameters are not yet parsed, the parser will be invoked.

array getCookies()

This method returns the HTTP cookies sent in an HTTP request. If the cookies are not yet parsed, the parser will be invoked.

boolean setCookie( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )

Pancake\HTTPRequest::setCookie() will store a cookie that will be sent to the client when the request is finished. Works just like setcookie().