
34 Chapter 3
•
•
•
•
Example
Suppose that a file parameter is passed to a script with a parameter name of “testFile”. This
file can be accessed within a script as follows:
var path = req.getFileParamPath("testFile");
var m = new Media();
m.load(name @ path);
getHeaderNames()
Returns an array of all HTTP header names for the current request.
Syntax
req.getHeaderNames();
Parameters
This function has no parameters.
Example
function main() {
var respText = new TextResponse(TextResponse.TypePlain);
var headers = req.getHeaderNames();
for (var i = 0; i < headers.length; ++i)
{
respText.append(headers[i] + ": " +
req.getHeader(headers[i]) + "\n");
}
resp.setObject(respText, RespType.Streamed);
}
Sample Output
accept: */*
accept-encoding: gzip, deflate
accept-language: en-us
connection: Keep-Alive
host: localhost
user-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
Q312461)
getRequestURL()
Returns the full MRL that originated the request.
Syntax
var url = req.getRequestURL();
Parameters
This function has no parameters.