D. J. Bernstein
Internet publication

The httpd program

httpd handles an HTTP connection.


     httpd root

httpd prints requested public files from the root directory hierarchy. Normally root is /public/file.

httpd accepts GET and HEAD requests on standard input in HTTP/0.9, HTTP/1.0, and HTTP/1.1 formats, and responds on standard output:

If the file is unopenable or if httpd does not like the request, httpd prints an error message and exits. If httpd runs out of memory, encounters an I/O error, or does not receive an input packet within 60 seconds, it exits silently.

httpd also prints local log information on standard error.

httpd has exact-prefix support for If-Modified-Since: it uses code 304 if the Last-Modified contents are an exact prefix of the If-Modified-Since contents.

Normally httpd is run under tcpserver to handle HTTP connections from hosts around the Internet.

File handling

A request for http://v/f refers to the file named ./v/f inside the root directory hierarchy, if f does not end with a slash. A request for http://v/f/ refers to the file named ./v/f/index.html.

httpd always converts the host name v to lowercase. HTTP/0.9 requests and old HTTP/1.0 requests do not specify a host name; in this case httpd uses the host name 0.

If it successfully opens the file, httpd uses the file name to select a file type for HTTP/1.0 and HTTP/1.1.


httpd chroots to root when it starts. It then sets its group id and user id to the numbers given in environment variables $GID and $UID, as set by envuidgid.

httpd does not allow dots immediately after slashes in file names. It changes these dots to colons before attempting to open the file.

httpd will refuse to read a file if the file

Unsupported features

httpd does not support file modification requests such as POST.

httpd does not support SSI or CGI.

httpd rejects requests specifying Content-Length, Transfer-Encoding, Expect, If-Match, If-None-Match, or If-Unmodified-Since.

httpd does not generate its own directory listings, even if index.html does not exist. httpd rejects requests for directory names without terminating slashes; it does not redirect the requests.