httpGetMethod()

The function returns the HTTP method of the last HTTP message.

Synopsis

string httpGetMethod(int idx);

Parameter

Parameter Description
idx The client index (internal number of the client).

Return value

The function returns the HTTP method - see description.

Error

Errors can be queried with getLastError(). Errors can be:

Description

The function returns the HTTP method of the last HTTP message. Call the function in the callBack function.

Example

#uses "CtrlHTTP"


main()


{


  httpServer(false, 8080, 0); //Installs and activates an HTTP server


  httpConnect("example", "/firstExample"); /* Registers the CTRL function "example"


  as a Web resource */


  httpSetMethodHandler("DELETE", "deleteCB"); //Example of httpSetMethodHandler


  /* In this example, this is the local client and it sends the HTTP DELETE message


 */


  string result;


  netDelete("http://localhost:8080/firstExample", result);


  if ( result == "done" )


  DebugN("resource was deleted");


 }


 string deleteCB(string clientIP, string url, int idx)


 {


 DebugN("client " + clientIP + " has requested to delete " + url);


 string s = httpGetMethod(idx); /* Returns the last HTTP method that was called: In this case the method "DELETE" is returned. */


 DebugN("The last method:", s);


 return "done";


}


 string example() //creates an HTML page


 { /* The example returns an HTML page: */


 return "<html><head><title>First example</title></head>"


 "<body>This is my first example</body></html>";


}

Assignment

CTRL PlugIn

Availability

CTRL, UI