| 1 | =pod | ||
| 2 | |||
| 3 | =begin classdoc | ||
| 4 | |||
| 5 | Base class for CGIHandler classes. | ||
| 6 | Provides an interface definition for the single handleCGI() method. | ||
| 7 | <p> | ||
| 8 | Copyright© 2008, Dean Arnold, Presicient Corp., USA<br> | ||
| 9 | All rights reserved. | ||
| 10 | <p> | ||
| 11 | Licensed under the Academic Free License version 3.0, as specified in the | ||
| 12 | License.txt file included in this software package, or at | ||
| 13 | <a href='http://www.opensource.org/licenses/afl-3.0.php'>OpenSource.org</a>. | ||
| 14 | |||
| 15 | @author D. Arnold | ||
| 16 | @since 2008-03-21 | ||
| 17 | @self $self | ||
| 18 | |||
| 19 | =end classdoc | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | package HTTP::Daemon::Threaded::CGIHandler; | ||
| 24 | |||
| 25 | use HTTP::Daemon::Threaded::Logable; | ||
| 26 | use base qw(HTTP::Daemon::Threaded::Logable); | ||
| 27 | |||
| 28 | use strict; | ||
| 29 | use warnings; | ||
| 30 | |||
| 31 | our $VERSION = '0.91'; | ||
| 32 | |||
| 33 | =pod | ||
| 34 | |||
| 35 | =begin classdoc | ||
| 36 | |||
| 37 | |||
| 38 | Constructor. Stores ContentParams, SessionCache, and Logger objects, | ||
| 39 | and performs any content-specific initialization. | ||
| 40 | |||
| 41 | @param LogLevel <i>(optional)</i> logging level; 1 => errors only; 2 => errors and warnings only; 3 => errors, warnings, | ||
| 42 | and info messages; default 1 | ||
| 43 | @param EventLogger <i>(optional)</i> Instance of a HTTP::Daemon::Threaded::Logger to receive | ||
| 44 | event notifications (except for web requests) | ||
| 45 | @param SessionCache <i>(optional)</i> threads::shared object implementing HTTP::Daemon::Threaded::SessionCache | ||
| 46 | @param ContentParams <i>(optional)</i> name of a ContentsParam concrete implementation | ||
| 47 | |||
| 48 | @returns a HTTP::Daemon::Threaded::CGIHandler object | ||
| 49 | |||
| 50 | =end classdoc | ||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | sub new { | ||
| 55 | my ($class, %args) = @_; | ||
| 56 | return bless \%args, $class; | ||
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | =pod | ||
| 61 | |||
| 62 | =begin classdoc | ||
| 63 | |||
| 64 | |||
| 65 | Generate and send content. Uses CGI protocol to extract request information | ||
| 66 | from either <code>%ENV</code> or the provided <cpan>CGI</cpan> object, | ||
| 67 | read additional content from STDIN, and write generated content to STDOUT. | ||
| 68 | <p> | ||
| 69 | <b.NOTE</b> CGI handlers should <b>NOT</b> <code>exit()</code> here, but | ||
| 70 | simply return <i>(ala FastCGI)</i>. In all other respects, this behaves like | ||
| 71 | regular CGI protocol. However, be advised that STDOUT is redirected to a scalar | ||
| 72 | <i>(via PerlIO :scalar layer)</i> until the complete response is generated, and | ||
| 73 | so the handler should be judicious about the size of content returned. Finally, | ||
| 74 | be advised that <code>%ENV</code> has been <code>local</code>'ized; thus, | ||
| 75 | any changes to it will <b>not</b> be seen by forked processes. | ||
| 76 | |||
| 77 | @xs | ||
| 78 | @param $cgi <cpan>CGI</cpan> object for the client | ||
| 79 | @param $session <i>(optional)</i> a HTTP::Daemon::Threaded::Session object, | ||
| 80 | if the application configured a SessionCache class, and if WebClient | ||
| 81 | was able to recover an existing session from such a SessionCache. | ||
| 82 | =end classdoc | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | sub handleCGI { | ||
| 87 | my ($self, $cgi, $session) = @_; | ||
| 88 | } | ||
| 89 | |||
| 90 | 1; |