[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Beginners' question: multi-threaded HTTP service




On Nov 20, 2012, at 12:34 AM, Pander wrote:


only this works:

char buf[1024];
int n;
while ((n = evbuffer_remove(req->buffer_in, buf, sizeof(buf))) > 0) {
   fwrite(buf, 1, n, stdout);
}
printf("\n");

Because in POST, browsers send the parameters in the request body.

For example, this form (assuming that your client is a browser):

<form method="POST">
	<input type="hidden" name="a" value="1">
	<input type="hidden" name="b" value="2">
	<input type="submit">
</form>

Will turn into this POST request:

POST /path HTTP/1.1
Content-Length: 7
Content-Type: application/x-www-form-urlencoded

a=1&b=2


After you copy the body from the input buffer into a null terminated buffer, you can parse it using evhttp_parse_query_str(). I guess that evhtp has similar function since it need to parse the query string, using the same format.

***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.