Tclhttpd Document Domain

The Document domain (see Tclhttpd Domains) supports the delivery of mime-typed content derived from files to a browser.

Tclhttpd is surprisingly efficient at delivering files, because having located the content in a file system from a URL, it uses Tcl's fcopy command to simply deliver the content by means of the underlying Tcl Core (which is written in C.)

The Document domain also supports a wide variety of content translation and negotiation, including powerful templates (see TclHttpd Templates), substitution and caching.

An instance of a Document domain is associated with a document root, which is a directory within some tcl file system.


Pseudo Code of Document Algorithm

  • Generate a path from the URL
    • Translate URL suffix to file path relative to this Document domain's DocRoot
    • Translate paths which specify personal home pages to absolute paths.
  • Get file content from path - these alternatives are tried in order
    • Look for a fresh template which generates the desired file
    • Look for an exact match for the requested file
    • Negotiate an acceptable available alternative file and issue a redirect to it
    • Pass off to the Tclhttpd cgi domain looking for a Cgi in the middle of the path
  • Transform and return content according to type
    • a directory is handed off to the Dirlist module
    • a file transformed by a procedure Doc_$mimetype, or just returned verbatim if no such proc exists