HTTPD
[/?]
[/ACCESSLEVEL number]
[/VIRTUAL[+|-]]
[/INDEX string]]
[/DEFMIMETYPE string]
socket
HTTPD provides HTTP content (a.k.a. "origin") service, accepting HTTP queries on its input and sending HTTP responses on its output. If no socket is specified as an argument, it uses its standard input and standard output for input and output. Otherwise, it uses the named socket, which it closes when it has finished with it. The IP address and TCP port number on which content HTTP service is thus provided is determined by its parent process, not HTTPD itself. Conventionally, the port number is 80 and the IP address is one that is reachable by Internet at large.
HTTPD is designed to be spawned on demand by TCPSRUN. It can also be spawned by INETD, although the control of client access levels based upon the client's IP address, which TCPSRUN does, will be unavailable as a consequence.
Where client access is denied, HTTPD simply exits immediately, closing the socket. With any other access level, normal HTTP service is provided.
HTTPD accepts GET and HEAD requests. In
response to any other request it issues an error response and terminates.
The GET and HEAD requests may be in HTTP/1.0 or
HTTP/1.1 format.
In response to an HTTP/1.0 request, HTTPD outputs an HTTP/1.0 header, outputs the requested file or directory, and terminates.
In response to an HTTP/1.1 request, HTTPD outputs an HTTP/1.1 header, outputs the requested file or directory, and then loops around to listen for more requests.
HTTPD supports virtual hosting. Requests may omit the hostname from the
URL in the request. In which case, the hostname is taken from a Host:
header, if one is supplied. HTTP/1.0 requests are allowed to omit the
Host: header as well, in which case the hostname is the default hostname
"0". (HTTP/1.1 requests without hostnames cause an error response.)
If the /VIRTUAL option is enabled, a request for
http://host/path refers to the file or directory
./host/path relative to HTTPD's working directory.
If the /VIRTUAL option is disabled, a request for
http://host/path refers to the file or directory
./0/path relative to HTTPD's working directory.
In order to prevent the malicious from having access to arbitrary files and directories, HTTPD pre-processes the pathname, replacing any ".." pathname components with "//". (Proper processing of ".." in hyperlinks is supposed to be done by HTTP clients.)
If the pathname ends in a trailing slash, HTTPD first appends the default index filename to it. If the pathname indicates a directory, HTTPD responds with a client-side redirect message appending a trailing slash to the URL. If the pathname indicates a file, HTTPD serves up the file.
HTTP constructs the MIME content type for files from information in
extended attributes, if available. Failing that, it determins the
extension of the filename name, .ext, and looks for an environment
variable CONTENTTYPE_EXT_ext named after that
extension, and if the variable exists uses its value as the MIME content
type. Failing that, it falls back to the default MIME content type
specified.
HTTPD writes log information to its standard error, listing each request that is processed.
A "TCPService.RUN" run file, for HTTPD to be spawned by TCPSRUN, would typically look similar to:
program %APPS%\JdeBP\IU\Bin\HTTPD.exe argument HTTPD argument %3
TCPSRUN itself would be invoked under RUNSVC, the Service Manager in the OS/2 Command Line Utilities version 2.2, with a run file similar to:
program %APPS%\JdeBP\IU\bin\TCPSRun.exe chdir %_BOOT%:\Config\Services\%1 argument TCPSRun argument 0.0.0.0 argument www-http argument TCPService.RUN
/VIRTUAL/INDEXindex.html.
/DEFMIMETYPEtext/html.