Plexus: Internals

Plexus Internals

plexus.pl

Usage: plexus.pl config_file port running_as_root socket_filedescriptor

This routine is the main loop that accepts incoming connections on the socket and forks a process to handle the transaction. This way the server can continue to accept other connections while processing the actual data in the background. Plexus.pl is normally only called from the plexus startup code. Once the connection is established plexus.pl gets the request and logs it to the log file, then hands the request off to &process_input.

&process_input

The &process_input routine validates the request and hands it off to a support routine. Currently the only routine supported is &do_get, which handles GET requests from the the server.

&do_get

The &do_get routine handles mappings between the URL path and the actual data. For most documents the two will be the same but you can interpose translators using the %map associative array to specify alternate routines for handling the request. The default is $map{'__default__'} and as distributed is set to &retrieve. The mappings can be customized in the config file.

&retrieve

Decides if the requested path is a file or directory and calls either &send_file or &index_dir to handle it. If it's a file &retrieve first calls &deduce_content to decide what kind of file it is.

&deduce_content

Recursively looks up the file extension in %encoding and %ext to determine the file content and encoding. If unknown it uses the perl -B test to decide if it a binary file, if so it returns $content_binary; if not it returns $content_plain.

&send_file

Sends the specified file. If a content is specified then it also sends the standard MIME headers (plus any headers in %out_headers), otherwise the data is simply send as is (for use with other internal routines that must send several files to complete the document, they must send their own MIME headers).

&index_dir

Generates a listing for the files and directories in the specified path. If present, $dir_header is sent before the listing and $dir_footer is sent after the listing. There are default headers and footers provided if the files are not present. The listing includes the last modification time, size, and a directory/file indicator. ________________________________________
Tony Sanders