Global object that contains properties related to the current request.
|$req||Global object that contains properties related to the current request.|
|authUser||If a “Basic” auth token is supplied ion the header, this function will return the username part, otherwise “”.|
|authPassword||If a “Basic” auth token is supplied ion the header, this function will return the password part, otherwise “”.|
|data||Stores parameters to the request.|
|handled||set this to true to prevent requested page from processing|
|timeout||The maximum time in seconds this request should be allowed to run.|
|type||The type of http request.|
|rawData||Stores raw parameters to the request.|
|id||A unique identifier for this request|
|paramNames||A array of the parameter names passed to this request|
|contentText||content of the request body as a string|
|contentType||content type of the request|
|contentXml||content of the request body as an XML() object|
|contentByteArray||content of the request body as a Java byte|
If a “Basic” auth token is supplied ion the header, this function will return the username part, otherwise “”.
If a “Basic” auth token is supplied ion the header, this function will return the password part, otherwise “”.
Stores parameters to the request.
Every parameter in the HttpServletRequest is copied as a lowercase property of the data object.
If a parameter is passed multiple times, this property will the last passed value of the parameter. In addition, a property called <paramName>$array is created. This property contains an array of all the values of that parameter name, in the order they were passed. This parameter is created even if only one value is passed
If a parameter value can be interpreted as JSON, a property called <paramName>$object is created by calling String.parseJson against the value. If there are multiple JSON valid objects, only the last will be stored in parameter_name$object, but a property called parameter_name$objectArray is populated with every object created.
If a parameter contains dots (.) then is is presumed to be a property path and is interpreted via Object.setByPath. Thus a parameter called “Users.336642.firstName” can be accessed at $req.data.Users[“336642”].firstName
data parameters created via setByPath are not filtered through String.escapeHtml as described below
Every value in data.<paramName> and data.<paramName>$array is escaped via String.escapeHtml. This helps to protect against Cross-Site Scripting (XSS) and SQL injection. To access un-altered parameter data, see rawData
File uploads produce an object in $req.data containing information about the upload that looks like this
fieldName:String, name of field in form,
fileName:String, name of file on client side,
contentType:String, mime type,
isInMemory:boolean, true if file contents are in memory,
sizeInBytes:int, size in bytes,
diskLocation:String, the current location of the uploaded file
multiple uploads with the same fieldname are stored in $req.data.<fieldname>$array.
Upload progress can be tracked in a separate request/Thread via
which returns a progress object.
|fileNumber||File number currently being uploaded|
|bytesRead||Bytes uploaded so far for this file|
|totalBytes||Total bytes to be uploaded for this file|
|percentComplete||Percent complete as a ratio, from 0 to 1|
|kps||Upload rate in KiloBytes Per Second. Multiply this by 8 to get KiloBits per second|
|message||Generic message in the form of “Uploading file #1, 10% complete (200 KBps)”;|
|elapsedSeconds||total time in seconds since upload processing started|
Each header is keyed by how it appeared in the header, and as lowercase. This is because not every server formats header names the same. This means that if you are looking for a specific header, it is better to use
if ("user-agent" in $req.headers)
if("User-Agent" in $req.headers)
To avoid confusion when looping over key names, the lowercase key names are hidden and do not show up in Myna.dump() or $req.headers.getKeys()
The maximum time in seconds this request should be allowed to run. see “Default Request Timeout” in the administrator under General Settings. a value of 0 disables the timeout.
sets a property or nested object property of this object
Object.prototype.setByPath=function ( path, value )
replaces common symbols with their HTML entity equivalents
String.prototype.escapeHtml=function( string )