httpGetHeader()
Returns the value of the header (== key) of the last HTTP message.
Synopsis
string httpGetHeader(int idx, string key);
Parameter
Parameter | Description |
---|---|
idx | Idx ist the client index that was specified as last argument (after dyn_string headerValues) in the callback function - see example below. |
key | The name of the header - see example below. |
Return value
The value of the header (== key) of the last HTTP request.
Description
Returns the value of a specific header (the header that the key parameter includes) of the last HTTP message.
Example
The following example starts an HTTP server at the port 12000 without authentication, creates a form with text and executes the function httpGetHeader to return the value of the HTTP header.
#uses "CtrlHTTP"
int MAXLENGTH = 100 * 1024 * 1024; //100 MB
main()
{
//starts the HTTP Server at Port 12000 without authentication
httpServer(FALSE,12000);
httpSetMaxContentLength(MAXLENGTH);
/* Use http://localhost:12000/callBack1 URL in order to show the data */
/* httpConnect registers the function "callBack1" as a Web resource under the name "callBack1" */
httpConnect("callBack1","/callBack1");
}
//See rfc1867 for detailed information on form-based file uploads in HTML
string callBack1(blob content, string user, string ip, dyn_string headernames, dyn_string headervalues, int connIdx)
{
string formDoc = "<html><head><title>Test</title></head>" +
"<body>" +
"<p>Example page</p>" +
"</body></html>";
string host = httpGetHeader(connIdx, "Host"); //Returns the value of the header
DebugN("Host:",host);
return formDoc; //Returns the form
}
Assignment
CTRL PlugIn
Availability
CTRL