CivetServer::getParam is explicitly designed to read the parameters of a HTML form.
A form may look like this (
http://www.w3schools.com/html/html_forms.asp):
<form name="input" action="demo_form_action.asp" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>
If you enter "abcd" in the field, the submit button will lead to a GET request to
http://www.w3schools.com/html/demo_form_action.asp?user=abcd The GET request does not have body data, so mg_read will not return any data.
CivetServer::getParam(conn, "user", param) will give you
param=="abcd"Alternatively, you could use
method="post" in the form definition above. In this case, the submit button will lead to a POST request to
http://www.w3schools.com/html/demo_form_action.asp (without ?user=abcd), but the extra header field "Content-Length: 9" and 9 bytes body data user=abcd.
However
CivetServer::getParam(conn, "user", param) will give you
param=="abcd" again.
Calling CiverServer::getParam will consume all the body data, so your subsequent call to mg_read will not get anything anymore.
I do not use curl myself, so I am not sure what curl does. How does curl decide whether GET or POST is used?
Everything above is valid for browsers that implement forms, and
CivetServer::getParam(conn, ...) is adapted to exactly this use case.
In every other case, you should use mg_read to read the body data and mg_get_request_info(conn)->query_string to get the ?user=abcd from the url - there are never both in a HTML form.
You can use
CivetServer::getParam(const char *data, size_t data_len, ...), based on the
data not the
connection, to split the arguments later.