| 1 | package HTML::Mason::FakeApache; | ||||||||||||||||||||||||||||
| 2 | 2 | $HTML::Mason::FakeApache::VERSION = '1.60'; | |||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # We need to define an Apache package or we might get strange errors | ||||||||||||||||||||||||||||
| 7 | # like "Can't locate package Apache for | ||||||||||||||||||||||||||||
| 8 | # @HTML::Mason::FakeApache::ISA". We do the BEGIN/eval thing so that | ||||||||||||||||||||||||||||
| 9 | # the CPAN indexer doesn't pick it up, which would be ugly. | ||||||||||||||||||||||||||||
| 10 | 2 | ▶ | BEGIN { eval "package Apache" } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | @HTML::Mason::FakeApache::ISA = qw(Apache); | |||||||||||||||||||||||||||
| 13 | # Analogous to Apache request object $r (but not an actual Apache subclass) | ||||||||||||||||||||||||||||
| 14 | # In the future we'll probably want to switch this to Apache::Fake or similar | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use HTML::Mason::MethodMaker(read_write => [qw(query)]); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 8 | my $class = shift; | |||||||||||||||||||||||||||
| 20 | 8 | my %p = @_; | |||||||||||||||||||||||||||
| 21 | return bless { | ||||||||||||||||||||||||||||
| 22 | 8 | ▶ | query => $p{cgi} || CGI->new, | ||||||||||||||||||||||||||
|
Condition33%1/3
$p{'cgi'} || 'CGI'->new
MC/DC0%0/2
$p{'cgi'} || 'CGI'->new
$p{'cgi'}
'CGI'->new
Truth table33%1/3
A || B
A= $p{'cgi'}B= 'CGI'->new
| |||||||||||||||||||||||||||||
| 23 | headers_out => HTML::Mason::FakeTable->new, | ||||||||||||||||||||||||||||
| 24 | err_headers_out => HTML::Mason::FakeTable->new, | ||||||||||||||||||||||||||||
| 25 | pnotes => {}, | ||||||||||||||||||||||||||||
| 26 | }, $class; | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # CGI request are _always_ main, and there is never a previous or a next | ||||||||||||||||||||||||||||
| 30 | # internal request. | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub main {} | ||||||||||||||||||||||||||
|
Subroutine
main: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub prev {} | ||||||||||||||||||||||||||
|
Subroutine
prev: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub next {} | ||||||||||||||||||||||||||
|
Subroutine
next: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub is_main {1} | ||||||||||||||||||||||||||
|
Subroutine
is_main: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub is_initial_req {1} | ||||||||||||||||||||||||||
|
Subroutine
is_initial_req: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # What to do with this? | ||||||||||||||||||||||||||||
| 38 | # sub allowed {} | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub method { | ||||||||||||||||||||||||||
|
Subroutine
method: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 1 | $_[0]->query->request_method; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # There mut be a mapping for this. | ||||||||||||||||||||||||||||
| 45 | # sub method_number {} | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # Can CGI.pm tell us this? | ||||||||||||||||||||||||||||
| 48 | # sub bytes_sent {0} | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # The request line sent by the client." Poached from Apache::Emulator. | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub the_request { | ||||||||||||||||||||||||||
|
Subroutine
the_request: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 53 | $self->{the_request} ||= join ' ', $self->method, | ||||||||||||||||||||||||||||
| 54 | ( $self->{query}->query_string | ||||||||||||||||||||||||||||
| 55 | ? $self->uri . '?' . $self->{query}->query_string | ||||||||||||||||||||||||||||
| 56 | : $self->uri ), | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $self->{query}->server_protocol; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"the_request"} ||= join(" ", $self->method, $self->{"query"}->query_string ? $self->uri . '?' . $self->{"query"}->query_string : $self->uri, $self->{"query"}->server_protocol)
MC/DC0%0/2
$self->{"the_request"} ||= join(" ", $self->method, $self->{"query"}->query_string ? $self->uri . '?' . $self->{"query"}->query_string : $self->uri, $self->{"query"}->server_protocol)
$self->{"the_request"}
join(" ", $self->method, $self->{"query"}->query_string ? $self->uri . '?' . $self->{"query"}->query_string : $self->uri, $self->{"query"}->server_protocol)
Truth table0%0/3
A ||= B
A= $self->{"the_request"}B= join(" ", $self->method, $self->{"query"}->query_string ? $self->uri . '?' . $self->{"query"}->query_string : $self->uri, $self->{"query"}->server_protocol)
| |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # Is CGI ever a proxy request? | ||||||||||||||||||||||||||||
| 61 | # sub proxy_req {} | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub header_only { $_[0]->method eq 'HEAD' } | ||||||||||||||||||||||||||
|
Subroutine
header_only: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub protocol { $ENV{SERVER_PROTOCOL} || 'HTTP/1.0' } | ||||||||||||||||||||||||||
|
Subroutine
protocol: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub hostname { $_[0]->{query}->server_name } | ||||||||||||||||||||||||||
|
Subroutine
hostname: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # CGI says "use this when using virtual hosts". It falls back to | ||||||||||||||||||||||||||||
| 70 | # CGI->server_port. | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub get_server_port { $_[0]->{query}->virtual_port } | ||||||||||||||||||||||||||
|
Subroutine
get_server_port: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # Fake it by just giving the current time. | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub request_time { time } | ||||||||||||||||||||||||||
|
Subroutine
request_time: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | sub uri { | ||||||||||||||||||||||||||
|
Subroutine
uri: called CC=3 SCAR=13.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1 | ▶ | $self->{uri} ||= $self->{query}->script_name . $self->path_info || ''; | ||||||||||||||||||||||||||
|
Condition40%2/5
$self->{"uri"} ||= $self->{"query"}->script_name . $self->path_info || ""
$self->{'query'}->script_name . $self->path_info || ''
MC/DC0%0/2
$self->{"uri"} ||= $self->{"query"}->script_name . $self->path_info || ""
$self->{"uri"}
$self->{'query'}->script_name . $self->path_info
Truth table33%1/3
A ||= B
A= $self->{"uri"}B= $self->{'query'}->script_name . $self->path_info
| |||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # Is this available in CGI? | ||||||||||||||||||||||||||||
| 83 | # sub filename {} | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # "The $r->location method will return the path of the | ||||||||||||||||||||||||||||
| 86 | # <Location> section from which the current "Perl*Handler" | ||||||||||||||||||||||||||||
| 87 | # is being called." This is irrelevant, I think. | ||||||||||||||||||||||||||||
| 88 | # sub location {} | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 2 | ▶ | sub path_info { $_[0]->{query}->path_info } | ||||||||||||||||||||||||||
|
Subroutine
path_info: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub args { | ||||||||||||||||||||||||||
|
Subroutine
args: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | # Assign args here. | ||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | 0 | ▶ | return $self->{query}->Vars unless wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | # Do more here to return key => arg values. | ||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 2 | ▶ | sub headers_in { | ||||||||||||||||||||||||||
|
Subroutine
headers_in: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 102 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # Create the headers table if necessary. Decided how to build it based on | ||||||||||||||||||||||||||||
| 105 | # information here: | ||||||||||||||||||||||||||||
| 106 | # http://cgi-spec.golux.com/draft-coar-cgi-v11-03-clean.html#6.1 | ||||||||||||||||||||||||||||
| 107 | # | ||||||||||||||||||||||||||||
| 108 | # Try to get as much info as possible from CGI.pm, which has | ||||||||||||||||||||||||||||
| 109 | # workarounds for things like the IIS PATH_INFO bug. | ||||||||||||||||||||||||||||
| 110 | # | ||||||||||||||||||||||||||||
| 111 | $self->{headers_in} ||= HTML::Mason::FakeTable->new | ||||||||||||||||||||||||||||
| 112 | ( 'Authorization' => $self->{query}->auth_type, # No credentials though. | ||||||||||||||||||||||||||||
| 113 | 'Content-Length' => $ENV{CONTENT_LENGTH}, | ||||||||||||||||||||||||||||
| 114 | 'Content-Type' => | ||||||||||||||||||||||||||||
| 115 | ( $self->{query}->can('content_type') ? | ||||||||||||||||||||||||||||
| 116 | $self->{query}->content_type : | ||||||||||||||||||||||||||||
| 117 | $ENV{CONTENT_TYPE} | ||||||||||||||||||||||||||||
| 118 | ), | ||||||||||||||||||||||||||||
| 119 | # Convert HTTP environment variables back into their header names. | ||||||||||||||||||||||||||||
| 120 | map { | ||||||||||||||||||||||||||||
| 121 | 11 | my $k = ucfirst lc; | |||||||||||||||||||||||||||
| 122 | 11 | $k =~ s/_(.)/-\u$1/g; | |||||||||||||||||||||||||||
| 123 | 11 | ( $k => $self->{query}->http($_) ) | |||||||||||||||||||||||||||
| 124 | 2 | ▶ | } grep { s/^HTTP_// } keys %ENV | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"headers_in"} ||= "HTML::Mason::FakeTable"->new("Authorization", $self->{"query"}->auth_type, "Content-Length", $ENV{"CONTENT_LENGTH"}, "Content-Type", $self->{"query"}->can("content_type") ? $self->{"query"}->content_type : $ENV{"CONTENT_TYPE"}, map({my $k = ucfirst lc $_;
$k =~ s/_(.)/-\u$1/g;
$k, $self->{"query"}->http($_);} grep({s/^HTTP_//;} keys %ENV)))
MC/DC0%0/2
$self->{"headers_in"} ||= "HTML::Mason::FakeTable"->new("Authorization", $self->{"query"}->auth_type, "Content-Length", $ENV{"CONTENT_LENGTH"}, "Content-Type", $self->{"query"}->can("content_type") ? $self->{"query"}->content_type : $ENV{"CONTENT_TYPE"}, map({my $k = ucfirst lc $_;
$k =~ s/_(.)/-\u$1/g;
$k, $self->{"query"}->http($_);} grep({s/^HTTP_//;} keys %ENV)))
$self->{"headers_in"}
"HTML::Mason::FakeTable"->new("Authorization", $self->{"query"}->auth_type, "Content-Length", $ENV{"CONTENT_LENGTH"}, "Content-Type", $self->{"query"}->can("content_type") ? $self->{"query"}->content_type : $ENV{"CONTENT_TYPE"}, map({my $k = ucfirst lc $_;
$k =~ s/_(.)/-\u$1/g;
$k, $self->{"query"}->http($_);} grep({s/^HTTP_//;} keys %ENV)))
Truth table66%2/3
A ||= B
A= $self->{"headers_in"}B= "HTML::Mason::FakeTable"->new("Authorization", $self->{"query"}->auth_type, "Content-Length", $ENV{"CONTENT_LENGTH"}, "Content-Type", $self->{"query"}->can("content_type") ? $self->{"query"}->content_type : $ENV{"CONTENT_TYPE"}, map({my $k = ucfirst lc $_;
$k =~ s/_(.)/-\u$1/g;
$k, $self->{"query"}->http($_);} grep({s/^HTTP_//;} keys %ENV)))
| |||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | # Give 'em the hash list of the hash table. | ||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return wantarray ? %{$self->{headers_in}} : $self->{headers_in}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 1 | ▶ | sub header_in { | ||||||||||||||||||||||||||
|
Subroutine
header_in: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 133 | 1 | my ($self, $header) = (shift, shift); | |||||||||||||||||||||||||||
| 134 | 1 | my $h = $self->headers_in; | |||||||||||||||||||||||||||
| 135 | 1 | ▶ | return @_ ? $h->set($header, shift) : $h->get($header); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | # The $r->content method will return the entity body | ||||||||||||||||||||||||||||
| 140 | # read from the client, but only if the request content | ||||||||||||||||||||||||||||
| 141 | # type is "application/x-www-form-urlencoded". When | ||||||||||||||||||||||||||||
| 142 | # called in a scalar context, the entire string is | ||||||||||||||||||||||||||||
| 143 | # returned. When called in a list context, a list of | ||||||||||||||||||||||||||||
| 144 | # parsed key => value pairs are returned. *NOTE*: you | ||||||||||||||||||||||||||||
| 145 | # can only ask for this once, as the entire body is read | ||||||||||||||||||||||||||||
| 146 | # from the client. | ||||||||||||||||||||||||||||
| 147 | # Not sure what to do with this one. | ||||||||||||||||||||||||||||
| 148 | # sub content {} | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | # I think this may be irrelevant under CGI. | ||||||||||||||||||||||||||||
| 151 | # sub read {} | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | # Use LWP? | ||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub get_remote_host {} | ||||||||||||||||||||||||||
|
Subroutine
get_remote_host: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 155 | 0 | ▶ | sub get_remote_logname {} | ||||||||||||||||||||||||||
|
Subroutine
get_remote_logname: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 13 | ▶ | sub http_header { | ||||||||||||||||||||||||||
|
Subroutine
http_header: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 158 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 159 | 13 | my $h = $self->headers_out; | |||||||||||||||||||||||||||
| 160 | 13 | my $e = $self->err_headers_out; | |||||||||||||||||||||||||||
| 161 | my $method = exists $h->{Location} || exists $e->{Location} ? | ||||||||||||||||||||||||||||
| 162 | 13 | ▶ | 'redirect' : 'header'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $h->{"Location"} or exists $e->{"Location"}
MC/DC100%2/2
exists $h->{"Location"} or exists $e->{"Location"}
exists $h->{"Location"}
exists $e->{"Location"}
Truth table100%3/3
A or B
A= exists $h->{"Location"}B= exists $e->{"Location"}
| |||||||||||||||||||||||||||||
| 163 | 13 | return $self->query->$method(tied(%$h)->cgi_headers, | |||||||||||||||||||||||||||
| 164 | tied(%$e)->cgi_headers); | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 6 | ▶ | sub send_http_header { | ||||||||||||||||||||||||||
|
Subroutine
send_http_header: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 168 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 6 | ▶ | return if $self->http_header_sent; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 6 | print STDOUT $self->http_header; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 6 | $self->{http_header_sent} = 1; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 12 | ▶ | sub http_header_sent { shift->{http_header_sent} } | ||||||||||||||||||||||||||
|
Subroutine
http_header_sent: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | # How do we know this under CGI? | ||||||||||||||||||||||||||||
| 180 | # sub get_basic_auth_pw {} | ||||||||||||||||||||||||||||
| 181 | # sub note_basic_auth_failure {} | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | # I think that this just has to be empty. | ||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub handler {} | ||||||||||||||||||||||||||
|
Subroutine
handler: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 4 | ▶ | sub notes { | ||||||||||||||||||||||||||
|
Subroutine
notes: called CC=5 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 187 | 4 | my ($self, $key) = (shift, shift); | |||||||||||||||||||||||||||
| 188 | 4 | ▶ | $self->{notes} ||= HTML::Mason::FakeTable->new; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"notes"} ||= "HTML::Mason::FakeTable"->new
MC/DC0%0/2
$self->{"notes"} ||= "HTML::Mason::FakeTable"->new
$self->{"notes"}
"HTML::Mason::FakeTable"->new
Truth table66%2/3
A ||= B
A= $self->{"notes"}B= "HTML::Mason::FakeTable"->new
| |||||||||||||||||||||||||||||
| 189 | 0 | return wantarray ? %{$self->{notes}} : $self->{notes} | |||||||||||||||||||||||||||
| 190 | 4 | ▶ | unless defined $key; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 191 | 3 | ▶ | return $self->{notes}{$key} = "$_[0]" if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | 2 | return $self->{notes}{$key}; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 3 | ▶ | sub pnotes { | ||||||||||||||||||||||||||
|
Subroutine
pnotes: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 196 | 3 | my ($self, $key) = (shift, shift); | |||||||||||||||||||||||||||
| 197 | 0 | return wantarray ? %{$self->{pnotes}} : $self->{pnotes} | |||||||||||||||||||||||||||
| 198 | 3 | ▶ | unless defined $key; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 199 | 2 | ▶ | return $self->{pnotes}{$key} = $_[0] if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 1 | return $self->{pnotes}{$key}; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 10 | ▶ | sub subprocess_env { | ||||||||||||||||||||||||||
|
Subroutine
subprocess_env: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 204 | 10 | my ($self, $key) = (shift, shift); | |||||||||||||||||||||||||||
| 205 | 10 | ▶ | unless (defined $key) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 3 | $self->{subprocess_env} = HTML::Mason::FakeTable->new(%ENV); | |||||||||||||||||||||||||||
| 207 | 0 | return wantarray ? %{$self->{subprocess_env}} : | |||||||||||||||||||||||||||
| 208 | 3 | ▶ | $self->{subprocess_env}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | 7 | ▶ | $self->{subprocess_env} ||= HTML::Mason::FakeTable->new(%ENV); | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"subprocess_env"} ||= "HTML::Mason::FakeTable"->new(%ENV)
MC/DC0%0/2
$self->{"subprocess_env"} ||= "HTML::Mason::FakeTable"->new(%ENV)
$self->{"subprocess_env"}
"HTML::Mason::FakeTable"->new(%ENV)
Truth table66%2/3
A ||= B
A= $self->{"subprocess_env"}B= "HTML::Mason::FakeTable"->new(%ENV)
| |||||||||||||||||||||||||||||
| 212 | 7 | ▶ | return $self->{subprocess_env}{$key} = "$_[0]" if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 6 | return $self->{subprocess_env}{$key}; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 2 | ▶ | sub content_type { | ||||||||||||||||||||||||||
|
Subroutine
content_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 217 | 2 | shift->header_out('Content-Type', @_); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub content_encoding { | ||||||||||||||||||||||||||
|
Subroutine
content_encoding: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 221 | 0 | shift->header_out('Content-Encoding', @_); | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub content_languages { | ||||||||||||||||||||||||||
|
Subroutine
content_languages: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 225 | 0 | my ($self, $langs) = @_; | |||||||||||||||||||||||||||
| 226 | 0 | ▶ | return unless $langs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | my $h = shift->headers_out; | |||||||||||||||||||||||||||
| 228 | 0 | for my $l (@$langs) { | |||||||||||||||||||||||||||
| 229 | 0 | $h->add('Content-Language', $l); | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub status { | ||||||||||||||||||||||||||
|
Subroutine
status: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 234 | 0 | shift->header_out('Status', @_); | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub status_line { | ||||||||||||||||||||||||||
|
Subroutine
status_line: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 238 | # What to do here? Should it be managed differently than status? | ||||||||||||||||||||||||||||
| 239 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 240 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | my $status = shift =~ /^(\d+)/; | |||||||||||||||||||||||||||
| 242 | 0 | return $self->header_out('Status', $status); | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | 0 | return $self->header_out('Status'); | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 25 | ▶ | sub headers_out { | ||||||||||||||||||||||||||
|
Subroutine
headers_out: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 248 | 25 | my $self = shift; | |||||||||||||||||||||||||||
| 249 | 25 | ▶ | return wantarray ? %{$self->{headers_out}} : $self->{headers_out}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 8 | ▶ | sub header_out { | ||||||||||||||||||||||||||
|
Subroutine
header_out: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 253 | 8 | my ($self, $header) = (shift, shift); | |||||||||||||||||||||||||||
| 254 | 8 | my $h = $self->headers_out; | |||||||||||||||||||||||||||
| 255 | 8 | ▶ | return @_ ? $h->set($header, shift) : $h->get($header); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 15 | ▶ | sub err_headers_out { | ||||||||||||||||||||||||||
|
Subroutine
err_headers_out: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 259 | 15 | my $self = shift; | |||||||||||||||||||||||||||
| 260 | 0 | ▶ | return wantarray ? %{$self->{err_headers_out}} : $self->{err_headers_out}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 1 | ▶ | sub err_header_out { | ||||||||||||||||||||||||||
|
Subroutine
err_header_out: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 264 | 1 | my ($self, $err_header) = (shift, shift); | |||||||||||||||||||||||||||
| 265 | 1 | my $h = $self->err_headers_out; | |||||||||||||||||||||||||||
| 266 | 1 | ▶ | return @_ ? $h->set($err_header, shift) : $h->get($err_header); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | sub no_cache { | ||||||||||||||||||||||||||
|
Subroutine
no_cache: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 270 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 271 | 0 | $self->header_out(Pragma => 'no-cache'); | |||||||||||||||||||||||||||
| 272 | 0 | $self->header_out('Cache-Control' => 'no-cache'); | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 1 | ▶ | sub print { | ||||||||||||||||||||||||||
|
Subroutine
print: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 276 | 1 | shift; | |||||||||||||||||||||||||||
| 277 | 1 | print @_; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub send_fd { | ||||||||||||||||||||||||||
|
Subroutine
send_fd: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 281 | 0 | my ($self, $fd) = @_; | |||||||||||||||||||||||||||
| 282 | 0 | local $_; | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | ▶ | print STDOUT while defined ($_ = <$fd>); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | # Should this perhaps throw an exception? | ||||||||||||||||||||||||||||
| 288 | # sub internal_redirect {} | ||||||||||||||||||||||||||||
| 289 | # sub internal_redirect_handler {} | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | # Do something with ErrorDocument? | ||||||||||||||||||||||||||||
| 292 | # sub custom_response {} | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | # I think we've made this essentially the same thing. | ||||||||||||||||||||||||||||
| 295 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 296 | 2 | local $^W; | |||||||||||||||||||||||||||
| 297 | 2 | *send_cgi_header = \&send_http_header; | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | # Does CGI support logging? | ||||||||||||||||||||||||||||
| 301 | # sub log_reason {} | ||||||||||||||||||||||||||||
| 302 | # sub log_error {} | ||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub warn { | ||||||||||||||||||||||||||
|
Subroutine
warn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 304 | 0 | shift; | |||||||||||||||||||||||||||
| 305 | 0 | print STDERR @_, "\n"; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 8 | ▶ | sub params { | ||||||||||||||||||||||||||
|
Subroutine
params: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 309 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 310 | 8 | return HTML::Mason::Utils::cgi_request_args($self->query, | |||||||||||||||||||||||||||
| 311 | $self->query->request_method); | ||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 2 | 1; | |||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | ########################################################### | ||||||||||||||||||||||||||||
| 317 | package HTML::Mason::FakeTable; | ||||||||||||||||||||||||||||
| 318 | 2 | $HTML::Mason::FakeTable::VERSION = '1.60'; | |||||||||||||||||||||||||||
| 319 | # Analogous to Apache::Table. | ||||||||||||||||||||||||||||
| 320 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 321 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 23 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||
| 324 | 23 | my $class = shift; | |||||||||||||||||||||||||||
| 325 | 23 | my $self = {}; | |||||||||||||||||||||||||||
| 326 | 23 | tie %{$self}, 'HTML::Mason::FakeTableHash'; | |||||||||||||||||||||||||||
| 327 | 23 | ▶ | %$self = @_ if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | 23 | ▶ | return bless $self, ref $class || $class; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 7 | ▶ | sub set { | ||||||||||||||||||||||||||
|
Subroutine
set: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 332 | 7 | my ($self, $header, $value) = @_; | |||||||||||||||||||||||||||
| 333 | 7 | ▶ | defined $value ? $self->{$header} = $value : delete $self->{$header}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 2 | ▶ | sub unset { | ||||||||||||||||||||||||||
|
Subroutine
unset: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 337 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 338 | 2 | delete $self->{shift()}; | |||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 3 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 342 | 3 | tied(%{shift()})->add(@_); | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 1 | ▶ | sub clear { | ||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 346 | 1 | %{shift()} = (); | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 14 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 350 | 14 | tied(%{shift()})->get(@_); | |||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 1 | ▶ | sub merge { | ||||||||||||||||||||||||||
|
Subroutine
merge: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 354 | 1 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||
| 355 | 1 | ▶ | if (defined $self->{$key}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 356 | 1 | $self->{$key} .= ',' . $value; | |||||||||||||||||||||||||||
| 357 | } else { | ||||||||||||||||||||||||||||
| 358 | 0 | $self->{$key} = "$value"; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 2 | ▶ | sub do { | ||||||||||||||||||||||||||
|
Subroutine
do: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 363 | 2 | my ($self, $code) = @_; | |||||||||||||||||||||||||||
| 364 | 2 | ▶ | while (my ($k, $val) = each %$self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 2 | ▶ | for my $v (ref $val ? @$val : $val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | 2 | ▶ | return unless $code->($k => $v); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | ########################################################### | ||||||||||||||||||||||||||||
| 372 | package HTML::Mason::FakeTableHash; | ||||||||||||||||||||||||||||
| 373 | 2 | $HTML::Mason::FakeTableHash::VERSION = '1.60'; | |||||||||||||||||||||||||||
| 374 | # Used by HTML::Mason::FakeTable. | ||||||||||||||||||||||||||||
| 375 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 376 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | 23 | ▶ | sub TIEHASH { | ||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 379 | 23 | my $class = shift; | |||||||||||||||||||||||||||
| 380 | 23 | ▶ | return bless {}, ref $class || $class; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | 196 | ▶ | sub _canonical_key { | ||||||||||||||||||||||||||
|
Subroutine
_canonical_key: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 384 | 196 | my $key = lc shift; | |||||||||||||||||||||||||||
| 385 | # CGI really wants a - before each header | ||||||||||||||||||||||||||||
| 386 | 196 | ▶ | return substr( $key, 0, 1 ) eq '-' ? $key : "-$key"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 108 | ▶ | sub STORE { | ||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 390 | 108 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||
| 391 | 108 | ▶ | $self->{_canonical_key $key} = [ $key => ref $value ? "$value" : $value ]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | 3 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=5 SCAR=17.1
| |||||||||||||||||||||||||||||
| 395 | 3 | my ($self, $key) = (shift, shift); | |||||||||||||||||||||||||||
| 396 | 3 | ▶ | return unless defined $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | 3 | ▶ | my $value = ref $_[0] ? "$_[0]" : $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | 3 | my $ckey = _canonical_key $key; | |||||||||||||||||||||||||||
| 399 | 3 | ▶ | if (exists $self->{$ckey}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 400 | 2 | ▶ | if (ref $self->{$ckey}[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 401 | 0 | push @{$self->{$ckey}[1]}, $value; | |||||||||||||||||||||||||||
| 402 | } else { | ||||||||||||||||||||||||||||
| 403 | 2 | $self->{$ckey}[1] = [ $self->{$ckey}[1], $value ]; | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | } else { | ||||||||||||||||||||||||||||
| 406 | 1 | $self->{$ckey} = [ $key => $value ]; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 3 | ▶ | sub DELETE { | ||||||||||||||||||||||||||
|
Subroutine
DELETE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 411 | 3 | my ($self, $key) = @_; | |||||||||||||||||||||||||||
| 412 | 3 | my $ret = delete $self->{_canonical_key $key}; | |||||||||||||||||||||||||||
| 413 | 3 | return $ret->[1]; | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 42 | ▶ | sub FETCH { | ||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 417 | 42 | my ($self, $key) = @_; | |||||||||||||||||||||||||||
| 418 | # Grab the values first so that we don't autovivicate the key. | ||||||||||||||||||||||||||||
| 419 | 42 | ▶ | my $val = $self->{_canonical_key $key} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 420 | 39 | ▶ | if (my $ref = ref $val->[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 421 | 2 | ▶ | return unless $val->[1][0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 422 | # Return the first value only. | ||||||||||||||||||||||||||||
| 423 | 2 | return $val->[1][0]; | |||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||
| 425 | 37 | return $val->[1]; | |||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | 14 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 429 | 14 | my ($self, $key) = @_; | |||||||||||||||||||||||||||
| 430 | 14 | my $ckey = _canonical_key $key; | |||||||||||||||||||||||||||
| 431 | 14 | ▶ | return unless exists $self->{$ckey}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 13 | ▶ | return $self->{$ckey}[1] unless ref $self->{$ckey}[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 433 | 2 | ▶ | return wantarray ? @{$self->{$ckey}[1]} : $self->{$ckey}[1][0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | 6 | ▶ | sub CLEAR { | ||||||||||||||||||||||||||
|
Subroutine
CLEAR: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 437 | 6 | %{shift()} = (); | |||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | 26 | ▶ | sub EXISTS { | ||||||||||||||||||||||||||
|
Subroutine
EXISTS: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 441 | 26 | my ($self, $key)= @_; | |||||||||||||||||||||||||||
| 442 | 26 | return exists $self->{_canonical_key $key}; | |||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 5 | ▶ | sub FIRSTKEY { | ||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 446 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 447 | # Reset perl's iterator. | ||||||||||||||||||||||||||||
| 448 | 5 | keys %$self; | |||||||||||||||||||||||||||
| 449 | # Get the first key via perl's iterator. | ||||||||||||||||||||||||||||
| 450 | 5 | my $first_key = each %$self; | |||||||||||||||||||||||||||
| 451 | 5 | ▶ | return undef unless defined $first_key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 452 | 3 | return $self->{$first_key}[0]; | |||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 2 | ▶ | sub NEXTKEY { | ||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 456 | 2 | my ($self, $nextkey) = @_; | |||||||||||||||||||||||||||
| 457 | # Get the next key via perl's iterator. | ||||||||||||||||||||||||||||
| 458 | 2 | my $next_key = each %$self; | |||||||||||||||||||||||||||
| 459 | 2 | ▶ | return undef unless defined $next_key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 460 | 0 | return $self->{$next_key}[0]; | |||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 26 | ▶ | sub cgi_headers { | ||||||||||||||||||||||||||
|
Subroutine
cgi_headers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 464 | 26 | my $self = shift; | |||||||||||||||||||||||||||
| 465 | 26 | map { _map_header_key_to_cgi_key($_) => $self->{$_}[1] } keys %$self; | |||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | 9 | ▶ | sub _map_header_key_to_cgi_key { | ||||||||||||||||||||||||||
|
Subroutine
_map_header_key_to_cgi_key: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 469 | 9 | ▶ | return $_[0] eq '-set-cookie' ? '-cookies' : $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | 2 | 1; | |||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | __END__ | ||||||||||||||||||||||||||||