http server tutorials

OK, this is one of those “I have no idea where to look for this info, but a lot of people round here probably have overlapping interests” OT questions…

Where can I find information on how to implement an HTTP server? (not the HTTP protocol, but the server itself)

More specifically, I’d like a reference for people who want e.g. tutorials on writing HTTP servers that are a complement to the RFC. Personally, I’ve built up knowledge of the differnt HTTP servers - their architectures, their implementation details, their performance tricks etc - from many small observations and many different sources over the years. But when people ask “how do you do this?” I can’t find any easy pointers. The best I can come up with is “Uh, well you could try reading the Apache source code…” but that’s not a good solution really :(.

Or, even better, would be sites that compare and contrast web server implementation details (I know these exist - I’ve read articles on this topic going back many years; but I can’t remember where particular articles were nor would they be so relevant today).

The biggest problem I find is I can’t seem to construct google searches with any value. I keep hitting one billion variants of people trying to help each other install apache. (any search with “web server” or “http server” in on the web itself are, ahem, a bit hopeful :(). I’m still trying, but … anyone got some bright ideas? I’ve moved on to trying specialist searches (e.g. trying to find stuff specifically on how HTTP servers implement file transfer - just basic stuff like articles containing text saying “stream, don’t read-it-all-into-a-buffer-then-flush it (because you won’t be able to serve many files at once, nor any large files at all)” etc).

A take it you want to implelemt the whole thing
so just a servlet in a tomcat container would not be good enough
i.e.
http://java.sun.com/products/servlet/

Jeez why the hell you you want to do the whole thing?

This seems to be the area you would need to know about

http://www.developer.com/java/other/article.php/1488051

This assuming you would like to stick the way J2EE has abstracted the Http process.

Maybe I am complicating things. If you want the http server to be just a static page server. Well it would be just a matter of on listeneing on a port. Descrabling the garbase that comes in. Then bundling some garbage back according to the RFC spec that was build from a cached copy of the files you are serving. Still, why you wouldn’t use apache that would surely be much more effecient.

Refine the question

I have a solution that I think makes sense, you can tell me if you agree. Search on this -

embedded web server

You’ll stop getting all those apache related articles. Since you want to write something from scratch, it appears, examining hardware embedded solutions should give you a good reference point. The design philosophy will be somewhat different than say Apache or Tomcat, but you also won’t have to deal with all the ‘extra’ stuff you might not care about - php, server side stuff, tons of security issues, massive configurability, etc.

Any way, here are two links I thought might prove informative -

http://www.computer.org/internet/v2n3/w3design.htm

http://www.microcontroller.com/wp/NSC_CR16/embedded_web_server.htm

Regards,
Dr. A>

[quote]I have a solution that I think makes sense, you can tell me if you agree. Search on this -

embedded web server
[/quote]
Ah, good idea! You’re absolutely right that I want to prune all the PHP stuff etc, but unfortunatly I might find I lose a lot of the software-related stuff that I do want (e.g. efficient streaming as mentioned earlier); but I’m sure I’ll get a lot closer than I have been - 20 pages of refined google searches and I found only one useful resource - and that isn’t even HTTP specific :(.

c.f. next post for more details on reasoning.

[quote]A take it you want to implelemt the whole thing
[/quote]
I don’t want to implement anything - I want information I can provide to others which explains how to implement it.

I want tutorials on how to implement things; running tomcat is the answer to a different kind of question.

HTTP servers are an excellent way for beginners to try out their programming expertise on real-life, non “toy” servers.

  • everyone has a free client to test with
  • protocol debugging is very simple due to HTTP’s base format (use telnet to manually connect)
  • HTTP is a very well known protocol, so most tools have special support (e.g. packet sniffers always have support for decoding HTTP packets)
  • it has some of the best RFC’s compared to the other non-trivial protocols
  • it is an extremely general-purpose protocol, useful for many real-life situations; it is used in a lot of games (though they don’t tell you that)
  • it has advanced practical features, like resuming of downloads

However, I don’t want to write a whole book on “how to write an HTTP server”; I could do it, but I’ve got better things to do with my life and I’m 99% sure that most of the info for this is already out there, and well-written by others.

Not really; J2EE hasn’t so much abstracted HTTP as mangled it IMHO. There’s little of practical use that implementors can learn from looking at J2EE servlets.