An overview on how GoServe works
(To make sense of this, you may need to read GOSERVE.DOC too.)
Whenever a client connects to your machine, it sends a 'request string'.
GoServe receives the string and passes it to a 'filter'. This filter (a
program, written in Rexx) checks that the request is valid, and normally
responds with a file (such as an HTML document or a GIF image file). It
is the filter's responsibility to choose or create the file, given the
incoming request string.
A sample filter (GoFilter.80) is provided--see commentary in that
program for details. In brief, it asks the server for the name of the
data directory, checks for certain errors, and then processes the
request according to the verb (method) specified in the request.
Notes:
-
The sample filter gets the root, or home, directory for the data it
is to serve by calling the DATADIR() function. The value this
returns is set by GoServe (which, in turn, is derived from the
GoServe startup parameter or the Directory Selection dialog).
-
Only the most common verbs are handled by the sample filter:
-
GET is the most common ('send me some data') request. In most
cases, this sends back a file to the client, using the GoServe
FILE command.
-
HEAD is the same as GET, except that the data are not sent back
to the client. GoServe automatically ensures that only
'header' lines, which describe the data, are sent. HTTP
requires that all servers handle both GET and HEAD verbs.
-
POST is used by a client when data are to be sent to the server
(for example, text filled in for a Form, or a "post" to a
newsgroup). When the data is known to be short (fewer than 250
characters), GET may be used instead; the specification of
which method to use is included in the <form ...> tag of the
source document.
-
A default document is provided if none is specified.
Conventionally, this is called 'index.htm' or 'index.html'; a
sample 'index.htm' is provided (you can rename this to 'index.html'
if you are using an HPFS disk).
-
The TYPE option, where specified on a FILE response, indicates that
the server should prefix an HTTP 'OK' response and header to the
beginning of the file returned. The TYPE option is followed by the
MIME type (e.g., text/html or image/gif) of the file being
returned. Web servers should normally always specify a TYPE on a
FILE command.
-
Requests should be specified in URI form in that forward slashes
should be used instead of backslashes to indicate directories. For
example, with the sample setup, the tag <a href="fred/%7Edata.htm">
would cause the filter to receive the URI '/fred/%7Edata.htm'. The
packed URI (third argument string) would then be 'fred/~data.htm'.
The filter then prefixes the home directory name, resulting in a
file specification such as 'd:/gohttp/fred/~data.htm'. This would
refer to the OS/2 file 'd:\gohttp\fred\~data.htm'. GoServe
(actually the OS/2 I/O routines) will make the appropriate '/' to
'\' adjustments.
-
Errors are signalled to the client by sending back files that start
with the appropriate HTTP header line; these are generated by an
internal subroutine, which can be modified for more detailed or
personal error messages. This subroutine could be made external if
the TEMPFILE value is passed as an argument when it is called.
-
The sample 'globemap' routine shows how the coordinates of a click
on an active image can be processed. This particular routine
returns the coordinates as a percentage of half the image size,
relative to the middle and with map-style coordinates (X is
positive to the East, Y is positive to the North).
-
Certain special 'test and control' requests are supported by the
sample filter (for example, return server statistics). In the
sample filter, these are only allowed from a client with the same
address as the server. Other possibilities include allowing 'ANY'
as the allowed name [so anyone can use them], or, conversely, using
a privately-selected URL for the controls--which would act as a
password. See GOSERVE.DOC for more information on control options.
-
HTTP defines a simple 'basic' access control mechanism, and an
example of using this is included in the filter and sample pages.
When used, the person using the browser is prompted for a userid
and password; the filter checks the validity of this.
[ previous section | GoHTTP | next section ]
From 'gohttp.doc', version 2.32.
Copyright © International Business Machines Corporation, 1994, 1995.
All rights reserved.