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 &wrap_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.

&wrap_file

Sends the specified file wrapped with an approprate MIME header as to the deduced Content-type. Also, handles doing any translations that are needed to get the file to an acceptable format. This part will probably change again in the future when translations are done better. See setext.pl for an example translator.

To send raw data use &raw_file.

&raw_file

Sends the data from the specified file out the socket. This is used for internal routines that need to combine several files into one document. They are responsible for sending the 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