tiny web server in D

Adam Ruppe destructionator at gmail.com
Thu Jul 14 09:48:58 PDT 2011


std.socket is too low level for serving webpages. It just provides
the means to talk on the network, but doesn't do any application
protocols like http.

I've written a little http server in D, but it uses linux system
calls instead of std.socket, so it only works on linux.

http://arsdnet.net/dcode

Check out httpd.d and netman.d in there. Also, my cgi.d can work
together with them to serve web apps through the mini web server.


But as you can see, a lot of the code is parsing and writing http.

When you go to a web site, your browser sends something like this
to the server:

GET /index.html HTTP/1.1
Host: mysite.com

Then, the server replies:

HTTP/1.1 200 OK
Content-Length: 13
Content-Type: text/plain
Connection: close

Hello, world!


Then the connection is closed and the get is complete.


More information about the Digitalmars-d-learn mailing list