HTTP4D embedded http provider
goughy
goughy at gmail.com
Sun Apr 15 05:27:14 PDT 2012
Hi,
I have just finished the first cut of an HTTP library to provide
application level support for HTTP (ie as a server, not a
client). The library provide a very simple mechanism for
processing HTTP requests both synchronously (via delegates) and
asynchronously (via std.concurrency) using request/response
objects.
eg.
import std.stdio;
import protocol.http;
int main( string[] args )
{
httpServe( "127.0.0.1", 8888,
(req) => req.getResponse().
status( 200 ).
header( "Content-Type", "text/html" ).
content(
"<html><head></head><body>Processed ok</body></html>" ) );
return 0;
}
The code is available on github:
https://github.com/goughy/d/tree/master/http4d
Note that this is alpha quality code, so YMMV. I would
appreciate some feedback, critiques, opinions etc. - particularly
in the area of it being "idiomatic" as I'm still finding my feet
in the D language.
The good thing is without any real performance tuning, I can push
through over 23,000 requests per second, and I'm sure there is
plenty of room for improvement.
Cheers.
More information about the Digitalmars-d
mailing list