TCP/IP Lean: Web Servers for Embedded Systems, Second Edition

In the previous two chapters, I looked at the theoretical aspects of miniaturizing a TCP/IP stack so that it fits onto a microcontroller and at a practical TCP implementation on a PIC16C76.
I now turn your attention to the PICmicro [1] Web server itself and look at the ways in which you can provide a range of Web pages for I/O control and monitoring, and I introduce dynamic content within the severe constraints imposed by the microcontroller architecture.
[1]PICmicro is the registered trademark of Microchip Technology Inc.
In Chapter 10, I got as far as the implementation of a Daytime server. This accepts an incoming TCP connection from a client, discards any incoming data, generates a response string, and closes the connection. The principal addition required by a Web server is that it must accept a request string, indicating the document that is to be provided. This request is in hypertext transfer protocol (HTTP) format, and the Web server must send an HTTP response header, followed by the required document.
I'm using the term "document" loosely to describe a resource (file) on the server that is sent to the client. For the most part, the server doesn't care what the content of the documents are; it just puts an HTTP header on them and sends them out. There are a few exceptions to this rule.
Content-type. It is important that the HTTP header indicate the type of the data (HTML text, GIF...