home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
APPS
/
DATACOM
/
INTERNET
/
GOSERV
/
GOSERVE.DOC
< prev
next >
Wrap
Text File
|
1995-02-14
|
72KB
|
1,630 lines
GoServe 2.00
GoServe -- A Web and Gopher Server for OS/2
"""""""""""""""""""""""""""""""""""""""""""
Copyright (c) International Business Machines Corporation, 1993, 1995.
All rights reserved.
Introduction
""""""""""""
Two popular protocols for providing information on the Internet are the
HyperText Transfer Protocol (HTTP, used by World-Wide Web clients) and
Gopher (used by both Web and Gopher clients).
'GoServe' is a multi-purpose server for OS/2 which supports both these
protocols. The emphasis in the design of GoServe has been to make it
easy to become an information provider for the Internet, while not
inhibiting full use of the protocols by sophisticated users.
Providing that you already have TCP/IP installed, GoServe can be running
and serving files across a network in minutes; no reboot or editing of
configuration files is necessary. The GoServe package includes 'quick
start' instructions and working samples for both Web and Gopher servers.
GoServe processes requests from Web or Gopher clients using a Rexx
script to allow for customization. A server can handle requests from
many clients, using OS/2 threads and script caching for efficiency.
Multiple servers can be started (using different ports), and an audit
trail of requests and actions can be recorded. When running as a Web
server, much of the complexity of the Web protocol is handled
automatically; many GoServe users will only need to be concerned about
the data being provided, and need not be concerned about the mechanism.
While running, a graphical display of GoServe activity is shown (the
"Graphical Webspinner Interface"?), with optional response-time graphing
and an audible indication of connections. For control, various
restrictions may be employed to limit the load on the server machine.
Certain GoServe operations can be controlled remotely, if desired, using
any Web or Gopher client (or an OS/2 CMD program).
GoServe is a 32-bit OS/2 application, which requires OS/2 2.x or OS/2
Warp. GoServe requires TCP/IP for OS/2, or equivalent, to be installed
and operational (either on a real network or using the loopback driver).
A single copy of GoServe may be used as both a Web server and a Gopher
server at the same time, if required.
- - - - -
Mike Cowlishaw, IBM UK Laboratories
mfc@vnet.ibm.com
Getting started
"""""""""""""""
This document describes all aspects of the use of GoServe as a Web or
Gopher server. If you are a new user, you should first read one of:
o GoHTTP.doc -- for getting started setting up a Web server
o GoGopher.doc -- for getting started setting up a Gopher server.
Both of these guide you through setting up a working server. It's
recommended that you do this before reading more of the technical
details in this document. This document assumes that you are familiar
with Web or Gopher concepts, and have access to (and know how to use) a
Web or Gopher client.
How GoServe is used
"""""""""""""""""""
GoServe is an ordinary 32-bit OS/2 application program (it has no
special privileges, and uses only public interfaces to OS/2 and to
TCP/IP). When started, you should specify as a parameter the protocol
that the server is to use (HTTP or GOPHER).
When started, GoServe sets up a TCP/IP socket on the 'well-known' port
for the protocol selected (this can be altered using a different startup
parameter), then waits for requests from clients. When a request from a
client arrives, it is recorded in the audit file (if desired) and then
the GoServe filter for the port is called.
The GoServe filter is a program written in Rexx, which is given details
of the client and the request string. The filter decides on the
information (usually a file, containing a document or other data) to be
sent to the client, and returns details to GoServe. GoServe then sends
the HTTP response and the data to the client and closes the TCP/IP
connection.
Each incoming request is given a new OS/2 thread for communication,
filter processing, and response. GoServe handles all the details of
threads and TCP/IP communications, so you need only be concerned with
the filter (which can be very simple, perhaps just the sample filter)
and the data (documents, images, etc.).
Installation
""""""""""""
If you followed either of the 'getting started' documents, you will have
already installed GoServe. In general, only two files (plus data) are
needed to run GoServe as a Web or Gopher server: the GOSERVE.EXE program
file, and the appropriate Rexx filter. The default filter name has
filename GOFILTER, with an extension that is the TCP/IP port number to
be used (for example, 'GOFILTER.80' for the filter for a default Web
server, or 'GOFILTER.70' for the filter for a Gopher server). The
filter must be in the working directory for GoServe.
It is recommended that GOSERVE.EXE and the Rexx filter be placed in one
directory (for example, 'D:\GoServe'), and data for the server be placed
in a different directory. By default, the latter is expected to be
on the same drive as the GoServe directory, and named '\gohttp' for a
Web server or '\gogopher' for a Gopher server.
Both the data directory and the filter name can easily be changed by
using the GoServe options notebook or by a command line option, if
required.
In all cases, the Rexx filter must be in the working directory for
GoServe. The working directory is also used by GoServe for the
GOSERVE.INI file (which holds user settings, such as window position and
audit selections), and for any Audit and Audit Archive files.
When you unzip the GOSERV.ZIP file, you should find the following files:
goserve.doc -- this document
gohttp.doc -- how to get started as a Web server
gogopher.doc -- how to get started as a Gopher server
goserve.exe -- the server program
gofilter.80 -- sample (working) filter for HTTP
gofilter.70 -- sample (working) filter for Gopher
moveaud.cmd -- sample (working) remote control command
makeicon.cmd -- installation aid
gohttp.zip -- sample pages, etc., for a Web server [unzip to a
separate directory, perhaps D:\GoHTTP]. This also
includes the GoServe Web documentation in HTML.
gogopher.zip -- sample menus, etc., for a Gopher server [unzip to a
separate directory, perhaps D:\GoGopher]
license.txt -- IBM license agreement for OS/2 Tools
Please see the 'how to get started' documents for step-by-step
instructions for installation.
--- Uninstalling GoServe ---
To uninstall GoServe, it is only necessary to delete the directories
used by GoServe, with their contents. No changes are made to the OS/2
system. (Note that prior to version 1.74, GoServe saved settings in
OS2.INI. Later versions automatically migrate this information to the
GoServe working directory.)
--- Requirements ---
GoServe is a 32-bit OS/2 application, which requires OS/2 2.x or OS/2
Warp. For OS/2 Warp, version 1.31 (or later) of GoServe is needed.
GoServe requires TCP/IP for OS/2, or equivalent, to be installed and
operational (either on a real network or using the loopback driver).
Over time, CSDs for TCP/IP become available--if TCP/IP problems are
suspected, always try the latest CSD.
Filter programs
"""""""""""""""
Filter programs are written in Rexx. Based on the arguments they are
passed, they decide on the document or other data to be sent to the
client and then issue a command or return a result that defines that
data (usually a file) to the server. GoServe then handles the
transmission of the data to the client.
All requests are passed to the Rexx filter, so for every request you
have full control over the response by modifying the filter as required.
GoServe will never send data to a client without the filter being
involved.
The filter is cached (that is, it and its tokenized version are only
read from disk when changed) and is executed on the same thread as the
incoming request (not as a separate process). This is very efficient;
informal measurements suggest that only a small percentage of the total
response time of a simple request is spent in running the filter. For
example, the total time to run the sample filter on a 486/50MHz PC has
been measured under OS/2 2.11 to be as little as 11ms.
For examples of filters, please see the sample filters in the GoHTTP or
GoGopher collections. The following is specific technical information
on how the filters work.
Three argument strings are passed to the filter:
1. The source of the request. This has four words [more words could
be added at the end in the future], separated by one or more
blanks:
o the Internet address (primary host identifier) of the server's
machine or cluster (in numeric form)
o the server's port number used for the connection
o the transaction number (a number, incremented for each new
request, that starts at 0 when GoServe is started)
o the Internet address of the client (in numeric form).
Example: "9.15.11.189 80 101 9.20.25.65"
2. The request string.
o For a Web server, this string is the HTTP request string,
exactly as received from the client. This comprises three
words: the request verb (e.g., 'GET'), the URI (Universal
Resource Identifier) or partial URI, and the HTTP protocol
identifier (e.g., 'HTTP/1.0'). The third word may be absent
when older (HTTP/0.9) clients connect. A URI of just '/'
indicates the initial contact from a client, and the filter
would normally respond with a default document ("home page").
Partial URIs are (or should be) the request string from a Web
'href' attribute previously sent to the client, unchanged
[except that extra data, such as incoming data from forms, may
be suffixed, and a leading slash, '/', may be added]. For
more information on URIs, see the technical details available
on the Web. A good place to start is the Web information
based at 'http://info.cern.ch/'.
o For a Gopher server, the request string is any data received
from the client up to (but not including) a Tab, Carriage
Return, or Line Feed. An empty request string indicates the
initial contact from a client, and the filter would normally
respond with a default Gopher menu. Otherwise, it will (or
should) be the request string from a Gopher menu line
previously sent to the client, unchanged.
You have complete freedom in setting request strings in Web documents
and Gopher menus, and in deciding how the filter should respond
depending on the string received. Very often, the name of a file is
used, and that file is sent to the client. [Note: it is recommended
that fully qualified filenames NOT be used for request strings.]
3. The extended request string.
o For an HTTP server, this string is the "packed" URI or partial
URI. This is the second word of the request string, with
escape sequences (e.g., '%7e') converted to a single byte, and
with any leading slash ('/'), if present, removed.
o For a Gopher server, this is the 'Gopher+' data. Some Gopher
clients can add additional information to a request, attached
to the request string after a Tab character. GoServe discards
the Tab character and presents the remainder as the third
argument to the filter. See Gopher protocol documents for
more information on how the extended selector string is used.
The filter can specify that GoServe send either a file or a single
string to the client, or request certain other GoServe operations.
All these operations are effected in the usual Rexx way, by using
commands, which are described later in this document. Other commands
allow more detailed control of the server.
The filter may also return a result string to GoServe; this, too, is
treated as a command. [In early versions of GoServe, this was the only
way to execute a GoServe command, so early GoServe filters only use that
mechanism.]
In addition to the commands, GoServe provides several special-purpose
functions for dealing with incoming requests. For example, the
PACKUR(string) function takes a string which has been encoded for safe
transmission, and reduces escape sequences (such as '%7E') to the
character encoding that they represent (in this case, '~').
Any failure of the filter (such as a syntax error) is considered
catastrophic and will cause GoServe to end.
Notes:
1. Remember that GoServe will run multiple copies of the filter at
once, on different threads, if more than one client connects at the
same time. If building temporary files, use the transaction number
and port as part of the file name.
2. The results of SAY instructions (or tracing) in the filter program
may be seen using the PMprintf package. However, Rexx interactive
tracing is not supported. PMprintf should be available from the
same source as GoServe.
3. You may change the name of the filter when starting GoServe or by
using the 'Filter selection' options page. The filter must always
be in the working directory for GoServe. If you make changes to
the default filter, it's a good idea to change its name, too, so if
you install a new version of GoServe your filter will not be
overwritten by the new default filter.
4. External subroutines, written in Rexx, are easily called from the
filter simply by using their name in a CALL instruction or function
call. The names should not match that of a Rexx built-in function,
and the routine should normally be in a file with the same
extension (e.g, '.80') as the filter and in the same directory.
5. You can execute OS/2 commands from the filter using the Address CMD
instruction, for example:
address cmd
'start e foo.bar'
'call d:\foobar\test.cmd argstring'
Use caution when calling external programs before the response is
complete: any slowness directly affects the response time to the
client and its user. Note also that separate processes (including
external commands) are not terminated automatically by GoServe if a
connection times out.
Finally, when executing commands, do not build any part of the
command string from data received from the client; this could allow
execution of arbitrary commands on your server (for example, if an
'&' command separator character were included in the data).
6. By default, each copy of a filter may have up to five files open at
once. This limit may be increased using the Limits selection
dialog (see elsewhere).
7. A new version of the filter is only cached (loaded) when GoServe is
idle; therefore, if you change the filter while GoServe is running,
the changes will not be used until the first client connects after
a time when there have been no clients connected.
8. For more information on Rexx, try connecting to the Rexx Language
page at: http://rexx.hursley.ibm.com/rexx
9. For more information on OS/2, try connecting to the IBM Almaden
Research Center server, at index.almaden.ibm.com. Both Web and
Gopher clients are supported (the server runs GoServe). The IBM
home page (http://www.ibm.com) is another good starting point for
OS/2 information.
Filter commands
"""""""""""""""
Commands may be executed by GoServe filters at any time, using the usual
Rexx command syntax (a clause that is just an expression). In addition,
any string returned by the filter will be executed as a command.
Certain commands (CLOSE, CONTROL, FILE, NODATA, and STRING) can be
'completion commands'; that is, after executing the command, the
response to the client will have been sent and will be complete. Only
one completion command may be executed for each request received; once a
completion command has been executed, no further commands will be
accepted.
If the filter ends without error and without executing or returning any
completion command, the server will generate one (currently "String [No
information available]").
Errors and failures in commands are reported by a non-zero return code
(which is placed in the Rexx variable RC), and also may raise the ERROR
or FAILURE condition if enabled by SIGNAL ON or CALL ON in the filter.
Command errors are also audited unless Error auditing has been turned
off. For details on the possible return codes, see "Command return
codes".
The total length of a command is limited to 1000 characters.
The most important commands are the completion commands, though there
are others which will be useful to filter writers. The commands follow
in alphabetical order; note that keywords and file specifications may be
in lower, upper, or mixed case.
AUDIT command
'''''''''''''
Syntax:
AUDIT string
The string supplied will be written to the Audit file as a 'user audit'
line. See "The audit mechanism" for a description of auditing.
CLOSE command
'''''''''''''
Syntax:
CLOSE
This command will cause GoServe to end, with return code set to 1, when
all current connections have been completed. No new connections will be
accepted. An acknowledgement is sent to the client, and the connection
is then closed, so this is a completion command.
CONTROL command
''''''''''''''''
Syntax:
CONTROL [VAR varname] options
A GoServe control action (such as moving the audit file, resetting
counters, or requesting statistics) is initiated, and a result string is
either placed in a Rexx variable or returned to the client.
This is used for controlling the GoServe server from the filter, either
directly or on request from a remote client or from another process on
the same machine -- for information on ways to do this, see "Remote
control of GoServe".
The possible options are:
o MOVEAUDIT
The audit file is copied to the archive file (just as though the
'Move audit to archive' Actions menu item had been selected).
o RESET [BYTES] [PEAK] [RESPONSE] [TRANSACTIONS] [ERRORS] [ALL]
The specified GoServe counters and statistics are reset (after
auditing, if appropriate). Any or all of the keywords may be given,
in any order. Each works in the same way as the corresponding
Actions menu item; RESPONSE refers to the response time record.
If ALL is used, all of the items are reset, and a record of the time
is kept; this time will be shown on the display window and in any
statistics requests.
o SAY string
The given string is returned; this can be used as a simple 'Loopback
test'.
o STATISTICS
Current statistics and settings are returned. These include:
1. Transaction, error, byte, and client counts, with a brief
response time analysis
2. Certain settings and options (not including audit selections)
3. The local time of certain events (if an event has not occurred,
it is shown as the GoServe start time).
The result of a CONTROL command is a single string, which may include
multiple lines, separated by Carriage Return-Line Feed (CR-LF, ASCII
'0d0a'x) sequences. The exact format is not defined. The result string
is either placed in a variable or returned to the client:
o If 'VAR varname' was specified, the result string is placed in the
named Rexx variable. The name of the variable is used just as if it
appeared in the filter program (for example, the name 'local.j'
might have the value of J substituted in the name).
o If 'VAR' was not specified, a document containing the string is
returned to the client (just as though the STRING command were
used), so in this case, CONTROL is a 'completion command'.
FILE command
''''''''''''
Syntax:
FILE [ERASE] [TYPE content-type] [BINARY|TEXT] NAME filespec
The file named by 'filespec' will be sent to the client. 'filespec'
should normally be a fully qualified name (if it is not, GoServe would
look for it in the GoServe working directory). Either forward or
backward slashes may be used as directory separators; the OS/2 file
systems accept either.
After this command has ended, the connection to the client is closed, so
this is a 'completion command'.
The optional keywords may be specified, in any order, and have the
following effects:
o ERASE -- the file is a temporary file, and should be erased after
being sent. [The transaction number and port can be used for
generating a safe name for a temporary file.]
o TYPE -- [HTTP protocol only] the file will be prefixed by an HTTP
"OK" response line and an HTTP header, including the content length
derived from measuring the file. The value of the TYPE option
('content-type') should be a Internet Media Type such as "text/html"
or "image/gif". See notes below for more information.
The TYPE option may only be used if GoServe is started with the HTTP
parameter (HTTP headers are not used by Gopher), and should normally
always be used when running as a Web server.
o BINARY -- [default for HTTP] the file is a binary file, and forms
the entire response to the client. GoServe will close the TCP/IP
connection as soon as the complete file has been sent.
A Gopher server should use this option for all files that are not
simple text or menus, for example ".ZIP" files, etc.
o TEXT -- [default for Gopher] the file is a text file: any trailing
DOS end-of-file character will not be sent to the client.
If running as a Gopher server, a Gopher terminator line (just a
period) will be sent at the end of the document, before the
connection is closed.
Here are some examples:
1. Returning an HTML file to a Web client:
file type text/html name d:/gohttp/index.htm
2. Returning a temporary image file to a Web client:
file erase type image/gif name d:/gohttp/$7681.80
3. Returning a .ZIP file to a Gopher client:
file binary name d:/gogopher/gogopher.zip
Notes:
1. The filespec may not include an 'upwards reference' sequence ("..\"
or "../"), as such a sequence could possibly allow clients access
to any file on the server machine.
2. All data sent to a client with an HTTP header should be described
by a Content-Type field in the header; GoServe will therefore only
generate a header automatically if the TYPE option was specified or
the HEADER command has been used to add header lines. In this
latter case, it is the responsibility of the filter to supply the
Content-Type field if the TYPE option was not used.
3. Internet Media Types were formerly known as MIME (Multipurpose
Internet Mail Extensions) Content Types. MIME is described in RFC
1521 and RFC 1522. The media types are used in the HTTP protocol
so that clients can determine how to process data received from
servers. Some common types are listed in the sample filter.
HEADER command
''''''''''''''
Syntax:
HEADER [NOAUTO] [{ADD|DROP} value]
Adds a header line to the HTTP response header, or drops one already
added. Header lines added by this command are sent to the client after
header lines generated automatically by GoServe. For example:
HEADER ADD Title: My own title
Blanks following the keyword ADD or DROP are removed by GoServe, so
continuation header lines must be started with the tab ('09'x)
character.
If DROP is used, only the field identifier (up to and including the
colon) should be specified. The first header line that matches (of the
lines added using HEADER ADD) is dropped, together with any following
continuation lines; automatically generated header lines are not
affected. A case-insensitive comparison is used for determining a
match.
NOAUTO may be used either alone on the command or in conjunction with
the ADD or DROP form. If any HEADER command specifies NOAUTO, no header
lines will be automatically generated by GoServe (except the final empty
line); all lines must be explicitly defined using HEADER ADD. For
example:
HEADER NOAUTO ADD Server: Special/0.01
HEADER ADD Title: Two-line header
At least one keyword must be used on the HEADER command. The HEADER
command has no effect under the Gopher protocol (though the command
syntax is checked). It also has no effect if the incoming request uses
HTTP/0.9 -- in this case, the protocol does not permit a header to be
returned, as it would be treated as part of the data.
NODATA command
''''''''''''''
Syntax:
NODATA [NORESPONSE]
No data is to be sent; the response is complete. For an HTTP/1.0
request, only a response line and header will be sent. For a Gopher (or
HTTP/0.9) request, the connection will simply be closed. This command
is intended to be used when only a header, or nothing at all, is to be
returned to the client.
If NORESPONSE is specified, then no response line and header will be
sent either, even for an HTTP/1.0 request; the connection will be
closed. This option could be used for testing, or if (say) a faulty
client was sending repeat messages.
NODATA is a 'completion command'.
READ command
''''''''''''
Syntax:
READ [BODY|HEADER] {VAR varname | FILE [APPEND] NAME filespec}
Reads (receives) information from an HTTP client. Either the header
lines or the body data are read, depending on whether HEADER or BODY was
specified, respectively. The default action is to read the body.
Then:
o If 'VAR varname' was specified, the header or body data are placed
in the named Rexx variable, as a single string. The name of the
variable is used just as if it appeared in the filter program (for
example, the name 'local.j' might have the value of J substituted in
the name).
o If 'FILE NAME filespec' was specified, the data are written directly
to the file named by 'filespec'. 'filespec' should normally be a
fully qualified name (if it is not, GoServe will write the file in
its working directory). 'filespec' may not include an 'upwards
reference' sequence ("..\" or "../"), as such a sequence could
possibly allow clients to modify any file on the server machine.
The named file is overwritten unless APPEND is specified (in which
case the data are written following the end of any existing data).
The READ command has no effect under the Gopher protocol, or if the
client did not send an HTTP/1.0 request (though in both cases the
command syntax is checked).
RESPONSE command
''''''''''''''''
Syntax:
RESPONSE responseline
Specify an explicit HTTP response (status) line. This replaces the
default 'OK' response generated by GoServe, and should be of the form
"HTTP/v.v nnn description", where 'v.v' refers to the HTTP version,
'nnn' is a 3-digit response code number, and 'description' is text (for
example, the default is "HTTP/1.0 200 OK").
HTTP only allows certain code numbers to be used, so refer to the HTTP
specification before using this command. The text should be short, and
is rarely seen, so GoServe will truncate the response line to 100
characters if necessary. If RESPONSE is executed more than once, the
last-executed command value is used.
The RESPONSE command has no effect under the Gopher protocol (though the
command syntax is checked). It also has no effect if the incoming
request uses HTTP/0.9 -- in this case, the protocol does not permit a
response line to be returned, as it would be treated as part of the
data.
STRING command
''''''''''''''
Syntax:
STRING string
The single string is returned to the client, with suitable preamble and
termination, depending on the protocol being used.
The STRING command can be used to return a simple message to the client.
Multiple lines can be sent, if necessary, by embedding a CR-LF sequence
('0d0a'x) to separate lines. A CR-LF is not needed at the end of the
string.
After this command has ended, the connection to the client is closed, so
this is a 'completion command'.
Command return codes
''''''''''''''''''''
When commands end, they report any errors or failures by setting the
Rexx variable RC. A value of zero indicates normal execution (no error
or failure was found), a positive value indicates an error, and a
negative value a failure. All command errors and failures are audited
with audit type 'E' (if auditing of errors is enabled).
The possible values for command return codes follow.
--- Errors ---
Errors indicate that the command was in error (perhaps a syntax error)
or the data it processed was in error. The following errors may occur:
[11] Response already completed
[21] Missing keyword in command
[22] Bad keyword in command
[23] Bad value in command
[24] Junk on end of command
[25] Header key not found
[31] Unable to open file
[32] Unable to read file
[33] Unable to write file
[34] Unable to write audit
[40] Bad variable name
[41] Could not set variable
[50] Missing Content-Length
[51] Bad Content-Length
[52] Zero Content-Length
[53] Multiple READ BODY requested
--- Failures ---
Failures are indicated when a command encounters an unexpected or
serious condition, such as a failure of the TCP/IP network or some limit
being exceeded. The following failures may be reported:
[-1] Inactive timeout exceeded
[-2] Total timeout exceeded
[-3] Header bytes limit exceeded
[-4] Body bytes limit exceeded
[-5] Out of memory
[-6] Failure reading from network
[-7] Failure sending to network
[-8] Unknown command
Filter functions
""""""""""""""""
In addition to GoServe commands, filters may use certain routines
provided by GoServe. These may be invoked either as functions or by the
CALL instruction, and are listed in the following sections.
DATADIR function
''''''''''''''''
Syntax:
DATADIR()
This returns the data directory name (e.g., 'd:/gohttp/') set up by
using the DATADIR option when starting GoServe or by using the DataDir
options page. (Once changed, GoServe records the data directory
associated with each port.)
The directory name will always end in a '/', and will use '/' as the
directory separator, "URI-style".
GMTOFFSET function
''''''''''''''''''
Syntax:
GMTOFFSET()
This returns the current offset from Greenwich Mean Time (GMT), in
seconds. A positive result indicates that your local time is ahead of
GMT by that amount.
If GMT cannot be computed because the TZ environment variable was not
set, the function returns a question mark (the character '?'). See
"Setting the TZ environment variable" for more information.
PACKUR function
'''''''''''''''
Syntax:
PACKUR(string)
Takes a single string, expressed according to the Universal Resource
(UR) specification (RFC 1630), as an argument and returns a packed
string. That is, hexadecimal escape sequences (such as '%7E') are
reduced to the character encoding that they represent (in this case,
'~').
PACKUR is especially useful for processing the incoming data from a
form, in which UR encoding is used. See the sample GOFILTER.80 for an
example of this use.
PACK64 function
'''''''''''''''
Syntax:
PACK64(string)
Takes a single string, expressed according to the MIME "Base64"
specification (in RFC 1521), as an argument and returns the decoded
(packed) string. Each four bytes in 'string' is packed to three bytes
in the result (except possibly for the last four bytes); 'string' must
be a multiple of 4 bytes. If any deviation from these specifications
(or from the RFC 1521 "Base64" character set) is found, the null string
is returned.
PACK64 is useful for processing the incoming user/password data encoded
for the HTTP 'basic access authentication scheme' -- see the HTTP
documentation for details.
REQFIELD function
'''''''''''''''''
Syntax:
REQFIELD(identifier [, count])
Searches the HTTP request header for a line that starts with the
specified identifier, and returns the value for that identifier.
Continuations are included in the value (if the continuation was
indicated by the tab character, the tab character is replaced with a
space).
The identifier may optionally end with a colon, and the search is
case-insensitive. If no matching identifier is found (or if there is no
HTTP request header), the null string is returned.
The second, optional, argument determines which value is returned if
more than one line starts with the given identifier: if no count is
given, the last matching line is used. If a count is given, then it
identifies which of the values is to be returned. For example,
reqfield("accept", 3)
would return the value of the third 'Accept:' line in the header
(perhaps "text/html"); if there was no third 'Accept:' line, then the
null string would be returned.
SERVER function
'''''''''''''''
Syntax:
SERVER([option])
The returns the name of the server software. If 'option' is omitted or
begins with the character 'N' (either case) then this is the full name
of the server software, followed by a comma, the word 'version', and the
version number of the server. For example, 'GoServe for OS/2, version
1.88'.
If 'option' begins with the character 'H' (either case) then the HTTP
short name is returned, for example, 'GoServe/1.88'. This is the same
as the value returned in the HTTP header field "Server:".
SERVERNAME function
'''''''''''''''''''
Syntax:
SERVERNAME()
This returns the primary host name of the server (for example,
'fred.mynet.org'), or if that should not be available, the name in
numeric form (e.g., 12.34.56.78).
If the latter case, your TCP/IP installation probably needs adjustment.
For example, if running in loopback mode and not on a real network, your
HOSTS file in TCPIP\ETC should contain your host name. Check also to
see what your TCP/IP HOSTNAME command (from an OS/2 prompt) returns;
again, it should be a full symbolic name (not the numeric form).
Running GoServe
"""""""""""""""
GoServe may be started in any of the usual ways, such as from an OS/2
command line or from a Program Reference object. You should always
specify the protocol to be used (HTTP or GOPHER) as a parameter to the
command. GoServe defaults to the Gopher protocol at present.
This section describes first the user interface to GoServe, and then
details the parameters that may be used when starting GoServe.
The GoServe window
''''''''''''''''''
Once GoServe has started, a PM window should appear. By default, a menu
bar is displayed giving access to the 'Options' notebook and an
'Actions' drop-down menu. Access to these is also provided at all times
by a pop-up menu if you click on the window with the context menu mouse
button (usually button 2).
To change the background color of the window, select the color of your
choice from the OS/2 color palette, drag it to the GoServe window, and
drop it. The color should change immediately.
The window is used to display a summary of the current and past activity
of GoServe. If it is large enough, it will include at the top a bar
display that shows any client activity (the full width of the bar
corresponds to the maximum number of clients allowed). A half-height
grey bar indicates the peak activity seen since GoServe was started.
This may be reset to zero by selecting 'Reset peak indicator' from the
Actions menu, and will be shown in purple if any errors have been
counted.
The second line of the window gives the total number of transactions
initiated since GoServe started, and the average response time of the
last 100 transactions. The color of this number changes to indicate
whether the response time goal is being attained; you can change the
goal (or turn off the coloring in the main window) using the 'Response'
page of the Options notebook. The response time is replaced by a count
of errors, if any have occurred.
If room, the second line shows on the right the instantaneous count of
connected clients and the peak number recorded since GoServe started (if
more than one).
The transaction count may be reset to zero by selecting 'Reset
transaction count' from the Actions menu). Similarly, the response time
record, error count, and peak count may also be reset to zero.
The third line shows the number of bytes, thousands of bytes, or
millions of bytes sent and received since GoServe started. These counts
may be reset to zero by selecting 'Reset byte counts' from the Actions
menu. The Actions menu also offers 'Reset all counts', which resets
all of the counters.
The fourth line of the window displays two timestamps; on the left is
shown the time when GoServe last entered the 'idle' state (that is, was
waiting for clients). On the right is the time when GoServe was
started (or when the last 'Reset All' was done).
Some or all of these items will be omitted if the window is too small
for satisfactory display.
The Options notebook
''''''''''''''''''''
If 'Options' is selected from the menu bar or pop-up menu, the Options
notebook is opened. This has the following pages:
1. 'Response' shows response time statistics, and lets you control
the display and coloring of the statistics.
At the top of the page, a bar chart shows the distribution of the
response times for recent requests, and (if there have been any
requests) the average response time. This bar chart is redrawn
automatically whenever the number of connections returns to idle,
or you can refresh it manually by clicking on (selecting) the
chart.
You can change the time-scale of this chart using the buttons at
the bottom right of the box. Any measurements that would be
"off-scale" (to the right of the chart) are included in the
bar at the far right of the chart.
The lower part of the page lets you set a response time goal using
a slider control; responses made within the specified time are
displayed on the bar chart in green; responses made within twice
that time are shown in an orangey-brown, and responses outside that
limit are shown in a medium-dark red. The exact colors used will
depend on your display.
The average response time shown on the page is colored according to
the the same rules, as is the less precise average response time
shown on the main window, if 'Color on main window' is checked.
See "Response time recording" for more details.
2. 'General' lets you change certain aspects of the appearance of the
main window, and control sounds made by the server.
Two 'Main Window' check-boxes are provided:
o 'Show menu bar' controls whether the menu bar is included in
the display. To make menu selections when there is no menu
bar, click anywhere on the GoServe window with the context menu
button, in the usual Workplace Shell manner (this works even if
the menu bar is visible).
o 'Surface on startup' lets you choose whether GoServe surfaces
its window when started (if not minimized when shut down).
The 'Sounds on connections' checkbox requests that sounds be made
(using the PC speaker) when a client browser connects to the
server. Radio buttons let you choose whether to hear a note (on a
ascending scale, depending on the number of connections) for every
connection, or to hear a note only when the server moves from being
idle to being busy (one or more connections).
3. 'Audit' lets you control the auditing of transactions (which events
are to be audited, and whether timestamps in the file are in local
time or GMT). See "The Audit mechanism" for more details.
4. 'Limits' (two pages) is used to control the operating limits of the
server. See "The Limits options pages" for details.
5. 'DataDir' lets you specify a new data directory name (path). This
name is made available to the Rexx filter via the DataDir()
function, and may be used by the filter to find the data to be
served. (But note that the filter may ignore this information, if
appropriate.)
GoServe will convert backslashes ('\') in the name to URI form
(forward slashes, '/'), and will add a trailing '/' if one is not
present. For example, entering 'd:\myhome' would result in the
directory specification 'd:/myhome/' being passed to the filter via
the DATADIR() function. This page checks that a drive is specified
so it is not accidentally omitted.
6. 'Filter' lets you specify a new filter name. This must be a simple
filename and extension (the extension will default to the port
number, if omitted).
The filter must be in the GoServe working (current) directory, so
no drive or directory path should be specified. For example, if
you enter 'myfilter.80', this would result in the filter
'd:\goserve\myfilter.80' being used, if 'd:\goserve' is the working
directory. The filter must exist in the GoServe working directory
in order for a new name to be accepted.
--- The Apply button ---
The 'Limits', 'DataDir', and 'Filter' pages let you choose when to apply
the change or changes that you make, by clicking on the 'Apply' button
(or pressing the Enter key). The Apply button is only enabled when you
have made a change and all fields on the page are valid. If you leave a
page (or close the notebook) when the Apply button is enabled, the
changes will be applied automatically at that time.
The Limits options pages
''''''''''''''''''''''''
The 'Limits' pages in the Options notebook let you change various limits
which apply to running GoServe. The limits are grouped into three sets:
limits affecting clients, timeouts, and (on the second page) limits
restricting incoming data.
--- Clients limits ---
The 'Clients' set has three limits:
1. 'Maximum at once' -- the maximum number of client connections
allowed concurrently [default 20]. Additional requests for
connection will be refused. This count lets you limit the maximum
load on your server, which is especially useful if it is also being
used as a personal workstation. Note that some Web clients, such
as Web Explorer, may make four or more connections at the same
time, to download inline graphics in parallel.
2. 'Show warning at' -- the percentage at which the bar chart will
show a red warning indicator [default 75%]. This gives a visual
indication of heavy use of your server at a given instant (the peak
use is also shown on the bar display).
3. 'Open files per client' -- the maximum number of open files
allowed, per client filter [default 5]. Increase this if you expect
your GoServe filter to have more than five files open at a time.
--- Timeouts ---
The 'Timeouts' set also has three limits; the first two timeout settings
control the time at which any uncompleted response may be terminated
automatically by GoServe's "watchdog" thread, and the third determines
how long GoServe will wait, on startup, for TCP/IP to become available:
1. 'End client after inactive' -- the "inactive timeout", in seconds.
A connection will be closed if the specified time passes without
any data being received or transmitted over the connection. The
default is 60 seconds.
2. 'End client after total' -- the "total timeout", in seconds. A
connection will be closed if the specified time passes since the
client connected to the port, even if there appears to be activity.
This value must not be less than the inactive timeout, and defaults
to 600 seconds. As a rule of thumb, this timeout might be set to a
number of seconds equal to or larger than the size of your largest
data file, expressed in kilobytes. This allows for transmission of
the file over a slow link running at one kilobyte per second.
3. 'Wait for TCP/IP start' -- the "start timeout", in seconds. This
is the time for which GoServe will wait on startup for TCP/IP to
become operational, while retrying appropriate TCP/IP calls as
necessary [default 600 seconds]. This allows asynchronous starting
of TCP/IP and GoServe. A value of 0 seconds means immediate
timeout (that is, no retrys are performed, and GoServe will not
start if an error is found). No TCP/IP retry is attempted if the
requested port is in use (that is, it is likely that another copy
of GoServe is already running).
Notes on timeouts:
1. For the first two timeouts, a value of zero seconds may be
specified to indicate an indefinite time (that is, the timeout
check is not made). You should only set both timeouts to zero if
the filter is trusted, the data it accesses is always available
locally, and all clients used with the server have a timeout
mechanism.
2. When the timeout takes place there may be some delay (typically up
to 15 seconds) before the transaction is interrupted. If the Rexx
filter is still running, it will have the HALT condition raised
during this process; the HALT condition may be trapped by CALL ON
HALT or SIGNAL ON HALT for necessary cleanup which should normally
be followed by an immediate EXIT.
--- Incoming data ---
The 'Incoming data' set is on the second Limits page (use the rightmost
button at the bottom of the first page, or Alt+Page Down, to get to it).
It has two limits which restrict how much incoming data will be accepted
by the server:
1. 'Header size' -- the maximum size (in thousands of bytes) of header
that will be accepted. The transaction will be ended if a header
is received that exceeds the specified size; this gives some
protection against a client that sends an invalid or never-ending
header. This limit is used whenever a header is read, either
automatically or because of the READ command. The default is 10
thousand bytes (10kB).
2. 'Body data size' -- the maximum size (in thousands of bytes) of
body data that will be accepted. The transaction will be ended if
a client sends data that exceeds the specified size, and an attempt
is made to read it using the READ command. The default is 50
thousand bytes (50kB).
Parameters on the GoServe command
'''''''''''''''''''''''''''''''''
Keyword parameters may be used when starting GoServe to set the protocol
(one only) and the TCP/IP port used, the default data directory, and the
action taken after a serious failure:
o The 'HTTP' parameter
This indicates that GoServe is being used as a World-Wide Web
server, using the Hypertext Transfer Protocol (HTTP). When this is
specified, the default port number is 80, the well-known port for
HTTP (this may be overridden as usual by the PORT parameter), and
other enhancements are enabled, including:
o The TYPE option may (and should) be used on FILE responses from
the filter.
o Automatic processing of both incoming and outgoing HTTP headers
is enabled (see "Automatic HTTP processing").
o Tab characters have no special significance in request strings;
the third argument passed to the filter is a 'clean' URI (see
"Filter programs").
o STRING and CONTROL command responses are returned as HTML
documents.
o The 'GOPHER' parameter
This indicates that GoServe is being used as a Gopher server, using
the Gopher Protocol. When this is specified, the default port
number is 70, the well-known port for Gopher (this may be overridden
as usual by the PORT parameter). The Gopher termination sequence (a
line containing just a single '.') is added to TEXT files and STRING
and CONTROL responses.
o The 'PORT n' parameter
The default port number for the selected protocol may be changed for
special applications by using the PORT parameter when starting
GoServe, for example:
start goserve http port 801
Servers started with different ports are independent; they use
different filter programs, and maintain a different collection of
options, window position information, audit file, etc.
Note that the port number is used as the required file extension for
some files--for port numbers greater than 999 you must therefore be
sure that the working directory for GoServe is on a disk that
supports extensions of more than three characters (for example, an
HPFS disk).
o The 'DATADIR d' parameter
This sets the data directory name (path) that will be used for this
port from the word following the keyword DATADIR. This name will be
used until the name is changed using the 'DataDir' Options notebook
page or by starting GoServe with a different DATADIR parameter. The
name should normally include the drive on which the data is to be
found.
The data directory name is not used directly by GoServe, but is made
available to the filter program via the DataDir() function--hence
allowing one filter to handle different data directories without
"hard-coding" their names in the filter.
GoServe will convert backslashes ('\') in the name to URI form
(forward slashes, '/'), and will add a trailing '/' if one is not
present. For example,
start goserve http datadir d:\myhome
would result in the directory specification 'd:/myhome/' being passed
to the filter via the DATADIR() function.
o The 'FILTER f' parameter
This sets the filter name that will be used for this port from the
word following the keyword FILTER. This name will be used until the
name is changed using the 'Filter' options notebook page or by
starting GoServe with a different FILTER parameter. The filter must
be in the GoServe working (current) directory, so no drive or
directory path should be specified. For example:
start goserve http filter myfilter.80
would result in the filter 'd:\goserve\myfilter.80' being used, if
'D:\goserve' is the working directory.
If no file extension is specified (that is, no period is found in
the name), the port will be added as the extension.
o The 'QUIETFAIL' parameter
Certain "catastrophic" errors (such as memory allocation errors, or
a syntax error in the Rexx filter) are considered failures by
GoServe; that is, they cause a message dialog to be displayed on the
screen--once the message is acknowledged, GoServe ends.
The QUIETFAIL parameter can be used to prevent the failure message
dialog being displayed:
start goserve http quietfail
In this case, GoServe will end immediately after a failure (after
attempting to audit the failure, as usual).
GoServe also accepts some experimental keyword parameters:
o 'TRACE' copies audit information to the PMprintf window (without
GoServe timestamps); this does not affect auditing to the audit
file. This lets you watch a trace of incoming requests, actions,
and errors as they happen without needing to look at the audit file
itself.
o 'REUSE' allows reuse of the port, even if some other application (or
TCP/IP) has not released it.
o 'DIAG' shows TRACE information together with additional details of
GoServe operation (also using PMprintf). This diagnostic
information is intended for development use and may change over
time. If you are observing unexpected GoServe behaviour, the DIAG
option may show helpful information. 'DIAG2' and 'DIAGMSG' may
provide even more verbose diagnostic information. 'DIAG' implies
'REUSE'.
Any number of GoServe parameters may be specified; the parameters may be
in any order. If a parameter with a value is specified more than once,
the last value is used.
GoServe return codes
''''''''''''''''''''
When GoServe ends, a return code is returned to the caller (for example,
when invoked from a Rexx program, this return code is placed in the Rexx
variable RC). The value is restricted by the operating environment to
be in the range 0 through 255; GoServe uses one of three possible
values:
[0] Normal completion (user action or OS/2 shutdown).
[1] GoServe was ended by the CLOSE filter command.
[8] Abnormal completion (failure), such as a syntax error in the filter.
Greenwich Mean Time (GMT)
"""""""""""""""""""""""""
The HTTP protocol (like most international networking protocols)
requires that dates and times, where used, be quoted in GMT. The
personal computers on which OS/2 runs, however, do not require that a
GMT clock be available--instead, the clock is usually set to local time.
Various mechanisms are used in OS/2 to indicate and calculate the
current offset from GMT. The most common is to use an OS/2 environment
variable named 'TZ', and for most people running GoServe this will
already be set (for example to 'EST5EDT' for the USA East Coast). See
the separate section on the value of the TZ variable.
If TZ is not set, GoServe will only use local time (and HTTP protocols
and header fields that require GMT will not be used or generated).
If the TZ variable is set, GoServe will convert from local time to GMT
as appropriate. It will also detect a clock dislocation (that is, when
the time-of-day clock is changed by more than 10 seconds) automatically,
and record and re-calculate the GMT offset when this occurs--such as
when you change your clock for daylight-savings time.
Notes:
1. You can see the offset that GoServe has computed by using the
CONTROL STATISTICS command or the GMTOFFSET() function.
2. For a few seconds between when you change the time and when GoServe
detects that it has been changed, incoming transactions may be
processed with anomalous time data; to avoid this, stop GoServe
before making large time adjustments and restart it afterwards.
3. Files in the PC-DOS and OS/2 FAT and HPFS file systems are
timestamped with the local time of creation or last modification.
The time-zone and daylight savings regime of that zone (and hence
the GMT offset) are not available. GoServe therefore calculates
the GMT timestamp of a file by using the current GMT offset.
4. If you're running your machine as a dedicated Web server, you may
want to set the clock to GMT and leave it set that way all year; in
this case, set TZ to 'GMT0'.
Response time recording
"""""""""""""""""""""""
GoServe records the response times of up to one hundred transactions.
'Response time', here, means the time from when the client connection is
accepted to when the first data bytes are sent. It may include the time
to receive some or all data from the client, but does not include the
time taken to send the response (which may be very large, and dependent
of network delays). Response times of transactions ended due to a
timeout or other limit being exceeded are not recorded.
The average response time, to the nearest 0.01 second, is shown on the
main GoServe window, next to the transactions count (unless an error has
occurred). A more precise figure, along with the number of transactions
over which it was recorded, is included in the CONTROL STATISTICS
response (this figure will not reflect the response time of the
transaction that initiates the CONTROL STATISTICS command). The same,
more precise, figure is also shown on the 'Response' page of the Options
notebook.
The GoServe response time directly affects the response time seen by the
person using the client browser, so it is desirable to keep this as low
as possible; the 'Response goal' setting in the Options notebook is
provided to make it easier to judge the performance of your server
setup.
The response times record may be reset using CONTROL RESET RESPONSE (or
the Actions menu item 'Reset response times').
Automatic HTTP processing
"""""""""""""""""""""""""
GoServe automates several aspects of the HTTP/1.0 protocol. (For full
details of the protocol, please see the HTTP specification.) When an
HTTP/1.0 request is received, the HTTP header lines are read
automatically (if needed). The Content-Length and If-Modified-Since
values are extracted as appropriate.
When a completion command is processed, GoServe will (if the incoming
request was HTTP/1.0) generate an appropriate response line and
HTTP header. For example, for a FILE command with a given file TYPE,
this will include the following header lines:
1. 'Server:' The name and version of the server (e.g., 'GoServe/1.88').
2. 'Date:' The message origination date and time (only if GMT can be
determined).
3. 'Message-ID:' A unique identifier for the message. For example,
'<19950101121030.80.123@my.host.name>', which is the local date and
time that the server was started, the port which it is serving, and
the transaction number, followed by the primary host name.
4. 'Content-Type:' The value set by the TYPE parameter.
5. 'Content-Length:' The length of the file (less 1, if TEXT was
specified and the file ends in an EOF character).
6. 'Content-Transfer-Encoding:' Currently always 'binary'.
7. 'Expires:' Set to the current time (only if GMT is available and
ERASE was specified on the FILE command).
8. 'Last-Modified:' Set to the timestamp of the file, converted to
GMT (only if GMT is available and ERASE was not specified).
Finally, GoServe will not actually send the body of the file if the
request verb was HEAD or if the 'Last-Modified' date is older or the same
as the first 'If-Modified-Since' date found in the request header (if
any). In this latter case, the response line will be 'HTTP/1.0 304 Not
Modified'.
Notes:
1. If the response line has been set explicitly by the RESPONSE
command, this overrides any possible "Not Modified" response, and
so the 'If-Modified-Since' check does not take place (that is, the
body of the response will be sent).
2. If the client does not send the header within a short time after
the request string, the 'If-Modified-Since' check may be bypassed.
This bypass is to allow for some older clients that are not fully
HTTP/1.0 compliant, and may be removed later.
3. GoServe does not automatically send a "MIME-Version" header field,
as it can make no guarantee that the message as a whole is
MIME-compliant (and in most cases it will not be).
The audit mechanism
"""""""""""""""""""
GoServe includes a built-in audit mechanism that records events in an
audit file while GoServe is running. This maintains a record of usage,
and also records any errors or failures of the server.
By default, all audit information (see details below) except selectors
is recorded. Choose the 'Audit' page of the Options notebook for
detailed control over which audit information will be written to the
audit file. You should only select auditing of 'Selectors' if the
recording of selectors (request strings) would not compromise
confidentiality or privacy.
The audit file has a fixed filename (GOAUDIT), with an extension that is
the TCP/IP port number used (for example, 'GOAUDIT.80'). It is written
in the working directory for GoServe.
For reliability, the audit file is written directly to disk and not
cached by the file system (though GoServe caches some informational
lines briefly to optimize response time). The audit file may be read
but not altered while GoServe is running.
Each line in the audit file starts with three words, separated by one or
more blanks: the time (hhmmss), the audit type (one character), and the
transaction number (a number, incremented for each request accepted,
that begins at 0 when GoServe is started). Additional information
follows, depending on the audit type:
A (Accept) - the numeric TCP/IP address of the client (n.n.n.n)
C (Complete) - response time (secs), and description of action
D (Day/Time) - the current day (yyyymmdd), and description of adjustment
E (Error) - description of an error in processing (e.g., timeout)
F (Failure) - description of the failure (terminating error)
I (Information) - description of information (statistics, etc.)
N (Network) - description of how network or client ended transaction
P (Port) - server identity and port (n.n.n.n nn)
S (Selector) - selector received from client
U (User) - description of event from User (filter) command
The times (and dates) recorded in the audit file may be in GMT (the
default) or in local time (the default for GoServe 1.41 and earlier).
The default may be altered using the 'Audit Selection' dialog, but note
that use of GMT is only possible if GMT times are available (that is,
the TZ environment variable was set when GoServe was started or when a
time dislocation was detected). If GMT is in use, the word 'GMT' is
added after the current day on 'D' audit lines.
Additional audit types may be added later. The format of any
"description" in the above is not strictly defined, except that all
Carriage Return, Line Feed, and End of File characters (ASCII '0d'x,
'0a'x, and '1a'x) are translated to '[', ']' and '#' respectively to
ensure audit file lines are well defined.
For example:
103701 D 0 19941225 GMT ----- GoServe 1.71 -----
103701 P 0 9.20.5.59 80
103726 A 1 9.20.5.59
103726 S 1 GET / HTTP/1.0
103727 C 1 0.9 Sent file "d:/gohttp/index.htm" [879 bytes]
103727 A 2 9.20.5.59
103727 S 2 GET /pmglobe.gif HTTP/1.0
103728 C 2 0.95 Sent file "d:/gohttp/pmglobe.gif" [1956 bytes]
103737 A 3 9.20.5.59
103737 S 3 GET /globe?22,40 HTTP/1.0
103738 C 3 0.9 Sent string "You clicked on the globe at [-36%, -16%]"
103745 A 4 9.20.5.59
103745 S 4 GET /samptest.htm HTTP/1.0
103746 C 4 1 Sent file "d:/gohttp/samptest.htm" [461 bytes]
103750 A 5 9.20.5.59
103750 S 5 GET /!statistics HTTP/1.0
103750 C 5 0.8 Control STATISTICS successful
103808 I 5 Bytes sent 5676 received 3045
103808 I 5 Close
Most transactions will end normally, with a 'C' line in the audit file.
If an error occurs, there may be one or more 'E' lines in the audit file
instead. If a transaction is ended by the client or network, than an
'N' line is used, which is not recorded as an error.
The response time recorded on 'C' lines is rounded down to the nearest
millisecond below, and measures the total elapsed time from receiving
the request to the first send of data to the client. This depends on
the speed of the processor and the work done by the filter, and may also
depend on network speed if data is read by the filter. (See "Response
time recording".)
After a FILE command, the time to send the data (as observed by the
server) is also included at the end of the description on the 'C' line.
This depends on the speed and activity of the server, client, and the
network between the two. It is likely to be rather variable.
--- Viewing or archiving the audit file ---
To look at an 'active' audit file, use a program or command that allows
shared reading of files. TYPE is one such command; its output may be
redirected to a file to take a snapshot copy of the audit file. For
example:
type goaudit.80 > snapshot.log
In addition, the Actions pull down menu has an item 'Move audit to
archive'. This closes the audit file, appends it to the GoServe archive
file in the current working directory, then erases and re-opens the
audit file. The GoServe filter can also initiate this action, by
returning "control moveaudit"--see "CONTROL command" for details.
The GoServe archive file has a fixed filename (GOARCH), with an
extension that is the TCP/IP port number used (for example,
'GOARCH.80'). It is only touched by GoServe during a "Move audit to
archive", so is readily copied, edited, or renamed.
Remote control of GoServe
"""""""""""""""""""""""""
GoServe filters (see "Filter programs") can request that GoServe perform
certain actions, instead of just returning files or other data. These
requests may be used to control GoServe remotely (from another machine
or from another process on the same machine). Control requests can
return a document containing one or more response lines, either showing
successful completion of the request or indicating an error.
Specifically, if the CONTROL command is used without the VAR option
(either from within the filter program or by being returned by the
filter) then the command action is performed and the result string is
returned to the client as a document.
The sample filters include examples of using control commands initiated
from standard menus or documents; these actions can be triggered
remotely using a Gopher or Web client, as appropriate. Rexx programs
can also use the OS/2 TCP/IP RxSock library (included in the UN64092
CSD, August 1994) to send a specific request to a GoServe server. A
sample command, MOVEAUD.CMD, is included in the GoServe package as an
indication of how this is used.
The filter mechanism provides flexibility in how control requests are
accepted and passed to GoServe, including the possibility of
modification so that only clients with certain addresses would be able
to use these options. The sample Web filter includes an example of how
this might be done.
Why not CGI?
""""""""""""
Many Web servers support a protocol known as the Common Gateway
Interface (CGI) for attaching and supporting scripts. GoServe does not
support this interface due to a number of difficulties with the design,
of which the most significant (in no particular order) are:
o The primary means of communicating information to scripts is by the
use of environment variables. These all have to be set before the
script is called, and as the number of these grow the overhead
approaches or exceeds the cost of interpreting the script. For
GoServe, Rexx variables could be set on startup -- but a clearer and
more efficient way of retrieving information is to use specialized
function calls (such as GoServe's REQFIELD) or general commands
(such as XEDIT's EXTRACT or GoServe's READ and CONTROL).
o Environment variables are a per-process resource in OS/2; GoServe's
scripts run on a per-thread basis (the script runs on the same
thread that handles the incoming connection, with no process
overhead or cleanup required).
o The piping of the incoming data to the script would often mean that
data is read even when unused, hence increasing the load on the
server (and, in some cases, on the network and client browser).
o For some servers, the output sent to the client is dependent on the
name of the script (for example, scripts whose name begins with
"nph-" may have their output treated differently from other
scripts).
o Server directives (commands sent to the server) are sent using the
same namespace (header lines) as the header information being sent
to the client. Separating this information, as in GoServe, leads to
a more reliable and extensible protocol.
o Binary executables are loaded from .EXEs rather than as functions in
a DLL (which would be at least twenty times faster).
o Standard output is used as a data channel to the server; this means
that the only data channel to the user (Webspinner) is standard
error, which is inappropriate for informative or status information,
often used while developing scripts.
For these reasons, it seemed unlikely that CGI scripts could be
supported directly (that is, without changes being required) with
reasonable efficiency by GoServe. GoServe's filters provide equivalent
function, and the processing logic will be essentially unchanged, so
ports of the algorithms required are easy.
Setting the TZ environment variable
"""""""""""""""""""""""""""""""""""
GoServe currently computes GMT from the local time-of-day clock (set by
the TIME and DATE commands) and the setting of the TZ environment
variable. The simple form of the value of TZ (which is suitable for use
in the USA or other countries that change to and from daylight savings
time at the same time as the USA) is as shown in:
SET TZ=EST5EDT
where EST is the standard time zone name (this must be exactly three
characters), EDT is the daylight savings time zone name (also exactly
three characters), and 5 is the difference between the standard time
zone and GMT, measured in hours West of GMT.
Note that the sign of the GMT offset used in the TZ variable is opposite
to that used for calculating the local time, given GMT, as returned by
the GoServe GMTOFFSET() function.
The simple form of TZ setting assumes that a 1 hour daylight savings
change starts at 01:00 on the first Sunday in April, and ends at 02:00
on the last Sunday of October.
For other countries, the full form of the TZ value has to be used. More
formally, this is:
SET TZ=SSS[+|-]nDDD,sm,sw,sd,st,em,ew,ed,et,shift
Where 'SSS', 'n', and 'DDD' are the values as in the simple form. In
the long form, all the other values must be specified, as follows.
'sm', 'sw', 'sd', and 'st' define the start time for daylight savings
adjustment, where:
o 'sm' is the starting month (1 to 12)
o 'sw' is the starting week (1 to 4 counting from the beginning, or -1
to -4 counting from the end). 0 indicates that a particular day of
the month is to be specified
o 'sd' is the starting day (0 to 6 [where 0 is Sunday] if 'sw' is
non-zero, or 1 to 31 if 'sw' is 0)
o 'st' is the starting time in seconds from midnight (e.g., 3600 for
01:00).
'em', 'ew', 'ed', and 'et' define the end time for daylight savings, and
take the same values.
'shift' is the shift in daylight time change, in seconds (e.g., 3600 if
one hour is to be added during daylight savings time).
For example, for the UK in 1995, the setting is expected to be:
SET TZ=GMT0BST,3,0,26,3600,10,0,22,3600,3600
Note that there appears to be no provision for time zone names of more
than three characters (blanks are allowed, so fewer that three
characters are OK). There also seems to be no provision for time zone
offsets that are not an integer number of hours.
[]