simple web server, mongrel, D

Unknown W. Brackets unknown at simplemachines.org
Thu Oct 12 22:14:36 PDT 2006


Actually, writing a simple web server in D wouldn't be hard.  Parsing 
HTTP/1.1 requests and such really isn't rocket science, and the biggest 
problem is just connection management and security, really.

That, of course, and efficiency and features.  It's unlikely you'll 
manage to beat out Apache, lighttpd, or what have you too easily in 
those regards.

-[Unknown]


> May be of interest to people doing web server stuff in D.
> 
> marcio
> 
> http://mongrel.rubyforge.org/faq.html
> Q: How is Mongrel designed?
> 
> The design of Mongrel most closely matches Simple 
> (http://simpleweb.sourceforge.net/) which is a very nicely designed web 
> server framework for Java. Despite being written in Java, Simple is very 
> clean and simple, thus the name (clever eh?). The main difference 
> between Mongrel and Simple is that Simple monitors returned output from 
> handlers so that it can modify the results. Mongrel instead uses Ruby’s 
> blocks to get the same effect.
> 
> As for the internals of Mongrel there are a few key technologies being 
> used:
> 
>     * A custom HTTP 1.1 parser written based on the RFC standard and 
> using an ABNF dump thankfully put online by someone. The parser is 
> written using Ragel and is written C as a Ruby extension.
>     * A URIClassifier that uses a Ternary Search Trie written by Peter 
> A. Friend and modified to quickly look up handlers for a URI based on a 
> prefix. This makes finding any handler from any URI quick and painless 
> and is much faster than the alternative of parsing the path and using 
> nested Hash structures.
>     * A simple server that uses the parser and URIClassifier to process 
> requests, find the right handlers, and then pass the results on to the 
> handler for processing.
>     * Handlers are responsible for using HttpRequest and HttpResponse 
> objects to do their thing and then return results.
> 
> Other than this there’s not much more to it.



More information about the Digitalmars-d mailing list