On Sun, Apr 15, 2012 at 6:27 AM, goughy <span dir="ltr"><<a href="mailto:goughy@gmail.com">goughy@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
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.<br>

<br>
eg.<br>
<br>
import std.stdio;<br>
import protocol.http;<br>
<br>
int main( string[] args )<br>
{<br>
    httpServe( "127.0.0.1", 8888,<br>
                (req) => req.getResponse().<br>
                            status( 200 ).<br>
                            header( "Content-Type", "text/html" ).<br>
                            content( "<html><head></head><body><u></u>Processed ok</body></html>" ) );<br>
    return 0;<br>
}<br>
<br>
The code is available on github: <a href="https://github.com/goughy/d/tree/master/http4d" target="_blank">https://github.com/goughy/d/<u></u>tree/master/http4d</a><br>
<br>
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.<br>

<br>
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.<br>
<br>
Cheers.<br>
<br>
<br>
</blockquote></div><br><div>Neat.  I like the integration with std.concurrency and the API in general (though I too am still trying to get a feel for idiomatic D).  How does 23,000 requests/sec compare to, say, nginx's performance (which seems to be the current performance king)? I just tried to look up some general performance figures but they are all over the place and don't correspond to your machine in any case.</div>
<div><br></div><div>I just watched the Go talk from Lang.NEXT and he uses Go's standard HTTP library and it made me a little jealous. Perhaps this would be a good candidate for Phobo's HTTP library.</div><div><br>
</div><div>Regards,</div><div>Brad Anderson</div>