CAB/Server/HTTP/Handler/Alias.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 46 CC 2 SCAR 10.3
CC
2
Cov
0%
run
6.0
BEGIN
2.0
new
2.0
CRAP 2.8
1 ##-*- Mode: CPerl -*-
2  
3 ## Alias: DTA::CAB::Server::HTTP::Handler::Alias.pm
4 ## Author: Bryan Jurish <moocow@cpan.org>
5 ## Description: DTA::CAB::Server::HTTP::Handler class: path alias
6 ##======================================================================
7  
8 package DTA::CAB::Server::HTTP::Handler::Alias;
9 use DTA::CAB::Server::HTTP::Handler;
10 use HTTP::Status;
11 use HTTP::Date qw();
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::Server::HTTP::Handler::alias' => __PACKAGE__,
22 'alias' => __PACKAGE__,
23 );
24 }
25  
26 ##--------------------------------------------------------------
27 ## $h = $class_or_obj->new(%options)
28 ## + options:
29 ## path => $aliasPath
30 sub new {
31 my $that = shift;
32 return bless { path=>'', @_ }, ref($that)||$that;
33 }
34  
35 ## $bool = $obj->prepare($srv)
36 sub prepare { return 1; }
37  
38 ## $rsp = $h->run($server, $localPath, $clientConn, $httpRequest)
39 sub run {
40 my ($h,$srv,$path,$csock,$hreq) = @_;
41 my $uri2 = $hreq->uri;
42 $uri2->path($h->{path});
43 my $h2 = $srv->getPathHandler($uri2);
44 return $srv->clientError($csock, RC_NOT_FOUND, "cannot resolve alias URI: ", $uri2->as_string) if (!$h2);
45 return $h2->run($srv,$path,$csock,$hreq);
46 }
47  
48  
49 1; ##-- be happy
50