[Mono-list] Web server

Clint Heyer clint@thestaticvoid.net
Sun, 10 Feb 2002 14:19:03 +1000

  I've been following the discussion about the needs for a web server. I 
started on my own very simple server a month ago that supports a few things 
that people are after. The big thing it doesn't support that people want is 
ASP, and the standard System.Web namespace classes. It currently supports 
Select() or asynchronous communications models (it's modular).

It has a 'handler' type model, so for a given Server (there can be 
multiple, later on for virtual host support), you can call:
  void AddContext(Context myContext);

Which would register myContext with the server. The model is similar to the 
Java servlet model. A `Context' object equates somewhat to the Java 
`Servlet' object. The way the server serves static pages is by using 
`FSContext' (filesystem context), which knows how to find, read and send 
files. A context to handle ASP files could be coded to work in a similar 
manner to IIS (hopefully with less security issues :), or a .NET object 
could be dynamically instansiated to handle requests as a servlet would. 
Request to context resolving is done by the server iterating though its 
contexts and asking them in turn if they support the request URI. The first 
context to say it can handles the request. Another method may be to do a 
hashtable lookup for the a URI component (eg '/cgi-bin'), which might be 
quicker (depending on how many contexts get loaded per server). Regex is 
also an option...

Anyway, the code is primitive, very developmental level (read: buggy, 
untuned, few comments, runs but there may be half completed code around) 
but it might be a start. I fairly confident that it supports most of the 
HTTP 1.0 spec, and parts of 1.1. If, heaven forbid, this is the best thing 
available, I would be prepared to release the source under an Open Source 
license, and help on getting the code integrated better with System.Web, 
and make it ASP.NET friendly. I've posted the code on 
http://student.uq.edu.au/~s359012/chwww.zip (37KB) if anyone wants to have 
a gander. The code is not currently under an Open Source license, so if you 
wish to use anything please contact me first.

If you want to test the code, modify the paths in Form1.cs, compile and 
run. It binds to port 81 by default, bindings are outputted on startup. 
That said, I think the .NET framework provides an excellent platform to 
build applications such as these, to allow for fine-grained access control 
for the server itself, as well as any classes loaded by the server during 


==[ Clint Heyer ]============================================
IRC: 'TheShadow' on irc.uq.edu.au
CELL: 04210-11-22-4
-------------------------[ http://thestaticvoid.net ]--------