Serving Web Pages
The Connection Manager can be used to serve your own web pages, in a similar manner to the Remote Administration pages. This is done by defining an <alias> in kconf.xml. The list of aliases can be viewed and edited by selecting the Display/Update web aliases link on the KCML System Configuration page.
An alias maps the URL that a browser will use to request the web page to a file or directory on the host's filesystem. An alias has the follow properties:
Property | Purpose |
---|---|
Alias Name | The alias name is used in the URL to request the page |
Real Name | The location of a file or directory on the host's filesystem |
Type | Controls how the requested URL is processed |
Authentication required | If set yo Yes, the a valid username and password will be required to view the page. |
Let's take an example of an alias called TestAlias. The Connection Manager will then use this alias when processing requests for a URL of the form http://hostname:790/TestAlias.
The behaviour of the web server, when processing a requested URL, depends on the Type of the alias.
Extension | Description | Supported platform |
---|---|---|
No extension, try to open the specified file first | All | |
.cmd | DOS command script | Windows only |
.bat | DOS batch file | Windows only |
.ksh | Unix Korn Shell script | All |
.sh | Unix Shell script | All |
.src | KCML source code program | All |
If the Real Name is the pathname to a KCML program, then the program is executed as a KCML script. The CGI script will inherit environment variables from the General section of kconf.xml, plus a set of CGI environment variables.
Variable | Typical Value or example | Purpose |
---|---|---|
SERVER_NAME | Hostname or IP address | Derived the hostname in a HTTP URL. |
SERVER_PORT | integer, typically 790 | Network port number that the Connection Manager is listening on. |
SERVER_SOFTWARE | kwebserv/06.90.00.nnnn | Program identifier and version |
PATH_INFO | myalias/cgi.ksh | HTTP URI, without query string |
PATH_TRANSLATED | /user1/app/htdocs/info/cgi.ksh | URI which has been translated to a file or directory on the host's filesystem |
QUERY_STRING | HTTP query string, ie the part of a URL after a ? character |
These environment variables can then be used by a CGI script to construct URLs for subsequent web pages.
The Connection Manager also allows a service to define its own aliases. When requesting pages that are defined in a per-service alias, the service name is used in the URL. For Example:
http://hostname:790/serviceName/TestAlias
The Connection Manager will expand any environment variables that are used in the Real Name value. Scripts that are executed using a CGIScript and CGIDirectory alias type will also inherit the service's environment variables.
It may be more convenient to define a list of aliases outside of kconf.xml. This can be achvied, in KCML 6.20 onwards, by storing the aliases in an included XML file. This include file is then referenced by adding an alias, in kconf.xml, with a Alias Name of 'include' and a Real Name which is the location of the the XML file.
From KCML 6.20 onwards, the Connection Manager supports HTTP Caching. When a web page is downloaded to a browser, the datestamp of the file is also sent. The web browser now 'knows' how old the file is. If the browser then requests the web page again, it sends this datestamp to the Connection Manager. The Connection Manager then compares this datestamp to the modification time of the file on host's filesystem. If the file has not changed, a tiny HTTP packet is sent back to the browser. This instructs the browser that its cached copy is up to date. If the file has been modified since, then the Connection Manager will resend the new page to the browser. The use of caching can greatly reduce the amount of network traffic for frequently requested web pages.
When a file is downloaded to a browser, the browser is told what type of data it is receiving. The browser can then decide how to process the data. This file type information called the MIME type and is deduced from the dot extension of the file's pathname. If the file has no dot extension, the contents of the file are scanned. However, this can be inefficient on large files. The list of MIME types and filename extensions that the Connection Manager recognized are as follows
MIME type | File extensions | Desciption |
---|---|---|
application/msword | doc | Microsoft Word document |
application/octet-stream | bin dms lha lzh exe class dll ocx drv com so sl | Binary files, e.g. executable programs, shared libraries |
application/pdf | Adobe Acrobat document | |
application/vnd.ms-excel | xls | Micorsoft Excel spreadsheet |
application/vnd.ms-powerpoint | ppt | Microsoft Point Point presentation |
application/x-cpio | cpio | Unix CPIO archive |
application/x-gtar | gtar | Gnu TAR archive |
application/x-gzip | gz gzip | GZIP archive |
application/x-javascript | js | Java script |
application/x-tar | tar | Unix TAR archive |
application/zip | zip | ZIP archive |
image/bmp | bmp | Windows BitMap image |
image/gif | gif | Graphics Interchange Format (GIF) image |
image/jpeg | jpeg jpg jpe | Joint Photographics Expert Group (JPEG) image |
image/png | png | Portable Network Graphics (PNG) image |
image/tiff | tiff tif | Tagged Image File Format (TIFF) image |
text/css | css | Cascading Style Sheet |
text/html | html htm | HyperText Markup Language (web page) document |
text/plain | asc txt ksh sh cmd bat | Text files, command scripts etc |
text/richtext | rtx | Text with formatting data |
text/rtf | rtf | Microsoft Rich Text Format |
text/sgml | sgml sgm | Standard Generalized Markup Language document |
text/tab-separated-values | tsv | Tab Separated Values data |
text/xml | xml dtd | eXtened Mark Langauage (XML) document |
application/xml | xsl | eXtensible Stylesheet Language transform script |
encoding/x-compress | Z | File compressed with the Unix compress command |