www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - simple web server, mongrel, D

reply Marcio <mqmnews123 sglebs.com> writes:
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=20
(http://simpleweb.sourceforge.net/) which is a very nicely designed web=20
server framework for Java. Despite being written in Java, Simple is very =

clean and simple, thus the name (clever eh?). The main difference=20
between Mongrel and Simple is that Simple monitors returned output from=20
handlers so that it can modify the results. Mongrel instead uses Ruby=92s=
=20
blocks to get the same effect.

As for the internals of Mongrel there are a few key technologies being us=
ed:

     * A custom HTTP 1.1 parser written based on the RFC standard and=20
using an ABNF dump thankfully put online by someone. The parser is=20
written using Ragel and is written C as a Ruby extension.
     * A URIClassifier that uses a Ternary Search Trie written by Peter=20
A. Friend and modified to quickly look up handlers for a URI based on a=20
prefix. This makes finding any handler from any URI quick and painless=20
and is much faster than the alternative of parsing the path and using=20
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=20
handler for processing.
     * Handlers are responsible for using HttpRequest and HttpResponse=20
objects to do their thing and then return results.

Other than this there=92s not much more to it.
Oct 12 2006
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
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.
Oct 12 2006