The following section provides some general information on the VMS HTTPd scripting enviroment.
Scripts are mechanisms for creating simple ``servers'' for accepting data from and sending data to a client, extending the services provided by the basic server. A DCL procedure is the basis for a script. An executable can be invoked by a script. TYPE-ing a file can be provide script output. Anything that can write to SYS$OUTPUT can be used to generate script output.
Specific scripts are enabled by VMS system management. Scripts cannot be
implemented by just anyone.
2.1 - CGI Compliance
The HTTPd scripting mechanism is designed to be largely WWW CGI (Common
Gateway Interface) compliant.
CGI Compliant Variables
Environment variables are created in a similar way to the CERN VMS HTTPD implementation, where CGI environment variables are provided to the script via DCL global symbols. These variables represent various aspects of the call to the script, aspects such as:
The basic CGI symbol names are demonstrated here with a call to a script that simply executes the following DCL code:
$ SHOW SYMBOL WWW_*Note how the request components are represented for ISINDEX-style searching (third item) and a forms-based query (fourth item).
Script output must behave in a CGI-compliant fashion (by way of contrast, see 2.2 - Non-CGI Compliance Output). That is, a CGI script may redirect the location of the document, using a Location: header line, or may supply a data stream beginning with a Content-Type: header line. Both must be followed by a blank line. The DEFORM utility can readily and transparently provide this functionality.
If the script output begins with either of the these two lines HTTPD
assumes that output will be line-oriented, without HTTP carriage-control (each
line terminated by a carriage-return then a line-feed), and will thereafter
ensure each record it receives is correctly terminated before passing it to
the client. In this way DCL procedure output (and the VMS CLI in general) is
supported transparently.
Example DCL Scripts
A simple script to provide the system time might be:
$ say = "write sys$output" $! the next two lines make it CGI-compliant $ say "Content-Type: text/plain" $ say "" $! start of plain-text script output $ show time
A script to provide the system time more elaborately (using HTML):
$ say = "write sys$output" $! the next two lines make it CGI-compliant $ say "Content-Type: text/html" $ say "" $! start of HTML script output $ say "<HTML>" $ say "Hello ''WWW_REMOTE_HOST'" !(CGI variable) $ say "<P>" $ say "System time on node ''f$getsyi("nodename")' is:" $ say "<H1>''f$cvtime()'</H1>" $ say "</HTML>"
A script does not have to output a CGI-compliant data stream. If it
begins with a HTTP header status line (e.g. ``HTTP/1.0 200
OK''), HTTPD assumes it will supply a raw HTTP data
stream, containing all the HTTP requirements. Any such script must observe
HyperText Transfer Protocol. Every line must be terminated by a
carriage return, then a line feed.
Non-CGI-Compliant DCL script
The following example show a non-CGI-compliant DCL script similar in function to the CGI-compliant one above. Note the full HTTP header and each line explictly terminated with a carriage-return and line-feed pair.
$ cr[0,8] = %x0d $ lf[0,8] = %x0a $ say = "write sys$output" $! the next line makes it non-CGI-compliant $ say "HTTP/1.0 200 Time follows.''cr'''lf'" $ say "Content-Type: text/html''cr'''lf'" $ say "''cr'''lf'" $! start of HTML script output $ say "<HTML>''cr'''lf'" $ say "Hello ''WWW_REMOTE_HOST'''cr'''lf'" !(CGI variable) $ say "<P>" $ say "System time on node ''f$getsyi("nodename")' is:''cr'''lf'" $ say "<H1>''f$cvtime()'</H1>''cr'''lf'" $ say "</HTML>''cr'''lf'"
The logical name HTTP$INPUT defines a mailbox providing the raw HTTP input stream from the client. This is available for procedures and executables to explictly open and read.
Note that this is a raw stream, and HTTP lines (carriage- return/line-feed terminated sequences of characters) may have be blocked together for network transport. These would need to be expliclty parsed by the program.
It is this stream that the DEFORM utility parses for the POST method..