File Coverage

blib/lib/Apache/Voodoo/MP/Common.pm
Criterion Covered Total %
statement 9 42 21.4
branch 0 4 0.0
condition 0 8 0.0
subroutine 3 19 15.7
pod 0 16 0.0
total 12 89 13.4


line stmt bran cond sub pod time code
1             package Apache::Voodoo::MP::Common;
2              
3             $VERSION = "3.0200";
4              
5 1     1   2029 use strict;
  1         2  
  1         36  
6 1     1   6 use warnings;
  1         2  
  1         30  
7              
8 1     1   5 use Time::HiRes;
  1         2  
  1         11  
9              
10             sub new {
11 0     0 0   my $class = shift;
12 0           my $self = {};
13              
14 0           bless $self,$class;
15 0           return $self;
16             }
17              
18             sub set_request {
19 0     0 0   my $self = shift;
20              
21 0           $self->{r} = shift;
22              
23 0           $self->{request_id} = Time::HiRes::time;
24              
25 0           delete $self->{'cookiejar'};
26             }
27              
28 0     0 0   sub request_id { return $_[0]->{request_id}; }
29              
30 0     0 0   sub dir_config { shift()->{r}->dir_config(@_); }
31 0     0 0   sub filename { shift()->{r}->filename(); }
32 0     0 0   sub flush { shift()->{r}->rflush(); }
33 0     0 0   sub method { shift()->{r}->method(@_); }
34 0     0 0   sub print { shift()->{r}->print(@_); }
35 0     0 0   sub uri { shift()->{r}->uri(); }
36              
37 0     0 0   sub is_get { return ($_[0]->{r}->method eq "GET"); }
38 0     0 0   sub get_app_id { return $_[0]->{r}->dir_config("ID"); }
39 0   0 0 0   sub site_root { return $_[0]->{r}->dir_config("SiteRoot") || "/"; }
40              
41             sub remote_ip {
42 0     0 0   return $_[0]->{r}->connection->remote_ip();
43             }
44              
45             sub remote_host {
46 0     0 0   return $_[0]->{r}->connection->remote_host();
47             }
48              
49             sub server_url {
50 0     0 0   my $self = shift;
51              
52 0           my $s = $self->{r}->subprocess_env('https');
53 0 0 0       my ($url,$p) = (defined($s) && $s eq "on")?('https',443):('http',80);
54              
55 0           $url .= '://'. $self->{r}->server->server_hostname();
56 0           my $port = $self->{r}->server->port();
57 0 0 0       if ($port && $port ne $p) {
58 0           $url .= ":$p";
59             }
60 0           return $url."/";
61             }
62              
63             sub if_modified_since {
64 0     0 0   my $self = shift;
65 0           my $mtime = shift;
66              
67 0           $self->{r}->update_mtime($mtime);
68 0           $self->{r}->set_last_modified;
69 0           return $self->{r}->meets_conditions;
70             }
71              
72             1;
73              
74             ################################################################################
75             # Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org).
76             # All rights reserved.
77             #
78             # You may use and distribute Apache::Voodoo under the terms described in the
79             # LICENSE file include in this package. The summary is it's a legalese version
80             # of the Artistic License :)
81             #
82             ################################################################################