line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::MobileAgent::Request; |
2
|
14
|
|
|
14
|
|
73
|
use strict; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
522
|
|
3
|
14
|
|
|
14
|
|
79
|
use Scalar::Util (); |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
7335
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
605
|
|
|
605
|
0
|
1019
|
my($class, $stuff) = @_; |
7
|
605
|
100
|
66
|
|
|
3904
|
if (!defined $stuff) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
8
|
550
|
|
|
|
|
3237
|
bless { env => \%ENV }, 'HTTP::MobileAgent::Request::Env'; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
elsif (ref $stuff eq 'HASH') { |
11
|
|
|
|
|
|
|
# PSGI hash - translate it to an HTTP::Headers object |
12
|
1
|
|
|
|
|
1120
|
require HTTP::Headers; |
13
|
2
|
|
|
|
|
11
|
my $hdrs = HTTP::Headers->new( |
14
|
|
|
|
|
|
|
map { |
15
|
2
|
|
|
|
|
16
|
(my $field = $_) =~ s/^HTTPS?_//; |
16
|
2
|
|
|
|
|
15
|
( $field => $stuff->{$_} ); } |
17
|
1
|
|
|
|
|
10052
|
grep { /^(?:HTTP|CONTENT|COOKIE)/i } keys %$stuff |
18
|
|
|
|
|
|
|
); |
19
|
1
|
|
|
|
|
114
|
bless { r => $hdrs }, 'HTTP::MobileAgent::Request::HTTPHeaders'; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif (UNIVERSAL::isa($stuff, 'Apache')) { |
22
|
1
|
|
|
|
|
7
|
bless { r => $stuff }, 'HTTP::MobileAgent::Request::Apache'; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
elsif (Scalar::Util::blessed($stuff) && $stuff->isa('HTTP::Headers')) { |
25
|
8
|
|
|
|
|
70
|
bless { r => $stuff }, 'HTTP::MobileAgent::Request::HTTPHeaders'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
45
|
|
|
|
|
442
|
bless { env => { HTTP_USER_AGENT => $stuff } }, 'HTTP::MobileAgent::Request::Env'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
package HTTP::MobileAgent::Request::Env; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get { |
35
|
1607
|
|
|
1607
|
|
2349
|
my($self, $header) = @_; |
36
|
1607
|
|
|
|
|
2332
|
$header =~ tr/-/_/; |
37
|
1607
|
|
|
|
|
10140
|
return $self->{env}->{"HTTP_" . uc($header)}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
package HTTP::MobileAgent::Request::Apache; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get { |
43
|
3
|
|
|
3
|
|
7
|
my($self, $header) = @_; |
44
|
3
|
|
|
|
|
15
|
return $self->{r}->header_in($header); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
package HTTP::MobileAgent::Request::HTTPHeaders; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub get { |
50
|
32
|
|
|
32
|
|
61
|
my($self, $header) = @_; |
51
|
32
|
|
|
|
|
121
|
return $self->{r}->header($header); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |