Finding scripts to run

The standard httpd requires users to keep scripts in separate directories from other files --- this struck me as all-around too inflexible, so I changed it. The current rules are as follows:

If a file named ../foo.doit is placed in a directory, that file will be invoked as a CGI script to handle HTTP GETs and POSTs to URLs of the form:

  • .../foo/bar/zot
  • .../foo?some+query+args
  • HTTP POSTs to .../foo (which is what happens when a user submits an HTML form which had METHOD=POST in its initial FORM tag).
  • HTTP GETs to .../foo, unless an actual file named foo is sitting in the file system alongside foo.doit. If such a file does exist, it will be retrieved for parameterless GETs, and the script will not be invoked. This allows 'coversheets' for ISINDEX documents to be put in a separate file, which is an occasional minor convenience.
  • The ellipses ('.../') in the pathnames and URLs above are meant to stand in for the usual process of URL-to-pathname translation, which translates an "open http://www.ai.mit.edu/xperimental/foo" which you might do in Mosaic into an attempt by the Web server to do something with the file /com/doc/web/xperimental/foo.

    There is another filename extension which can be used to roughly the same effect as .doit, which is '.nph'. The difference between .doit and .nph is that .nph scripts have complete control of the information sent to the client, and are therefore required to generate all HTTP/1.0 headers when talking to an HTTP/1.0 client, and required not to generate them when talking to an HTTP/0.9 client. These are details the server ordinarily takes care of. For most purposes, .nph isn't worth bothering with. These variant extensions replace a scungier naming scheme in the CGI/1.0 specification.

    One last special case --- in playing around, you may notice that .doit files cannot be retrieved directly (that is, an attempt to retrieve http://www.ai.mit.edu/xperimental/foo.doit will fail even if the file does exist, although an attempt to retrieve http://www.ai.mit.edu/xperimental/foo will properly invoke the script). This is an attempt on my part to make sure people don't export code without knowing about it --- if it gets in your way, just make a symlink.


    rst