Processing CGI Forms
Remotely
Randal L. Schwartz
CGI programs permit the Web surfer to perform actions affecting the state
of things on the Web server. In many cases, the Web server machine is also
where the neat stuff lives, so that the CGI script has direct access to files,
processes, and databases to fully respond to a request.
But sometimes the request needs to be shipped off from the machine that's
supposed to handle the CGI query to a machine that can actually handle the
query. For example, if you rent space on a virtual server to handle your customers'
page-fetching activities, and also have CGI scripts to let them ask questions
or order products, it's possible that the order-entry system actually lives
at another machine not directly accessible to the CGI scripts. How do we let
the CGI system access the order-entry system?
Well, one way is to let the CGI script perform the normal data-entry validation
-- retrying the form until the data is correct as far as can be determined
without connecting with the order-entry system -- and then bundle up a mail
message to the order-entry system. This mail message contains all the parameters,
so that the order-entry system can effectively "process the form," albeit
remotely.
Now, there's nothing terribly tricky about this, until you start considering
that form data might be tricky to flatten out into a mail message that survives
one or more hops through potentially hostile mail systems.