| 1 | ##-*- Mode: CPerl -*- | ||
| 2 | |||
| 3 | ## File: DTA::CAB::Server::HTTP::Handler::Response.pm | ||
| 4 | ## Author: Bryan Jurish <moocow@cpan.org> | ||
| 5 | ## Description: | ||
| 6 | ## + DTA::CAB::Server::HTTP handler class: static response | ||
| 7 | ##====================================================================== | ||
| 8 | |||
| 9 | package DTA::CAB::Server::HTTP::Handler::Response; | ||
| 10 | use DTA::CAB::Server::HTTP::Handler; | ||
| 11 | use HTTP::Status; | ||
| 12 | use Carp; | ||
| 13 | use strict; | ||
| 14 | |||
| 15 | our @ISA = qw(DTA::CAB::Server::HTTP::Handler); | ||
| 16 | |||
| 17 | ##-------------------------------------------------------------- | ||
| 18 | ## Aliases | ||
| 19 | BEGIN { | ||
| 20 | DTA::CAB::Server::HTTP::Handler->registerAlias( | ||
| 21 | 'DTA::CAB::Server::HTTP::Handler::response' => __PACKAGE__, | ||
| 22 | 'response' => __PACKAGE__, | ||
| 23 | ); | ||
| 24 | } | ||
| 25 | |||
| 26 | ##-------------------------------------------------------------- | ||
| 27 | ## Methods | ||
| 28 | |||
| 29 | ## $h = $class_or_obj->new(%options) | ||
| 30 | ## + %options | ||
| 31 | ## response => $obj, ##-- HTTP::Response object | ||
| 32 | sub new { | ||
| 33 | my $that = shift; | ||
| 34 | return bless { response=>undef, @_ }, ref($that)||$that; | ||
| 35 | } | ||
| 36 | |||
| 37 | ## $rsp = $h->run($server, $localPath, $clientConn, $hreq) | ||
| 38 | sub run { | ||
| 39 | my ($h,$srv,$path,$csock,$hreq) = @_; | ||
| 40 | return $h->cerror($csock, RC_NOT_FOUND) if (!defined($h->{response})); | ||
| 41 | return $h->{response}; | ||
| 42 | } | ||
| 43 | |||
| 44 | |||
| 45 | 1; ##-- be happy | ||
| 46 | |||
| 47 | __END__ |