[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] http server and infinite streams
I just whipped up a quick bare-bones http server using only bufferevents
and a MIT licensed http parser (which if I am not mistaken - is
compatible with bsd).
https://github.com/ellzey/bufferevent_http_parser/blob/master/evhttp.c
This is the type of control I would look for in a http request processig
API.
Send a POST request using curl with a very large file:
mthomas@uint:~/dev$ ./evhttp
Yay msg begin!
path = /
Header key: User-Agent
Header val: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7
OpenSSL/0.9.8l zlib/1.2.3
Header key: Host
Header val: localhost:8080
Header key: Accept
Header val: */*
Header key: Content-Length
Header val: 120261337
Header key: Content-Type
Header val: application/x-www-form-urlencoded
Header key: Expect
Header val: 100-continue
Yay fragment
Yay fragment
Yay fragment
Yay fragment
Yay fragment
....
....
....
Yay msg complete!
-------
The parser takes no responsibility of the data, only keeps a state of
where the parser is. This can be seen by the recv callback draining the
buffer at each call. Using this generic parsing approach while wrapping a
little more logic to abstract the "harder" parts of this API seems to me
a clear winner.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.