line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Engine::Test::Request; |
2
|
15
|
|
|
15
|
|
1025
|
use strict; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
615
|
|
3
|
15
|
|
|
15
|
|
82
|
use warnings; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
369
|
|
4
|
|
|
|
|
|
|
|
5
|
15
|
|
|
15
|
|
574675
|
use IO::Scalar; |
|
15
|
|
|
|
|
510949
|
|
|
15
|
|
|
|
|
794
|
|
6
|
15
|
|
|
15
|
|
196
|
use URI; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
357
|
|
7
|
15
|
|
|
15
|
|
853
|
use URI::WithBase; |
|
15
|
|
|
|
|
892
|
|
|
15
|
|
|
|
|
388
|
|
8
|
15
|
|
|
15
|
|
85
|
use Scalar::Util 'blessed'; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
1178
|
|
9
|
|
|
|
|
|
|
|
10
|
15
|
|
|
15
|
|
675
|
use HTTP::Engine::Request; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
448
|
|
11
|
15
|
|
|
15
|
|
4684
|
use HTTP::Engine::RequestBuilder::NoEnv; |
|
15
|
|
|
|
|
36
|
|
|
15
|
|
|
|
|
7141
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
8
|
|
|
8
|
0
|
10334
|
my $class = shift; |
15
|
|
|
|
|
|
|
|
16
|
8
|
100
|
66
|
|
|
109
|
if ($_[0] && ref($_[0]) && $_[0]->isa('HTTP::Request')) { |
|
|
|
66
|
|
|
|
|
17
|
|
|
|
|
|
|
# create H::E::Req from HTTP::Request |
18
|
4
|
|
|
|
|
8
|
my $req = shift; |
19
|
4
|
|
|
|
|
11
|
my %args = @_; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
18
|
return $class->build_request( |
22
|
|
|
|
|
|
|
$req->uri, |
23
|
|
|
|
|
|
|
$req->content, { |
24
|
|
|
|
|
|
|
headers => $req->headers, |
25
|
|
|
|
|
|
|
method => $req->method, |
26
|
|
|
|
|
|
|
protocol => $req->protocol, |
27
|
|
|
|
|
|
|
%args, |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} else { |
31
|
|
|
|
|
|
|
# create H::E::Req from hash |
32
|
4
|
|
|
|
|
13
|
my %args = @_; |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
100
|
|
|
19
|
my $body = delete $args{body} || ''; |
35
|
4
|
50
|
|
|
|
13
|
my $uri = delete $args{uri} or Carp::croak('missing uri'); |
36
|
4
|
50
|
|
|
|
12
|
my $method = delete $args{method} or Carp::croak('missing method'); |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
26
|
return $class->build_request( |
39
|
|
|
|
|
|
|
$uri, |
40
|
|
|
|
|
|
|
$body, { |
41
|
|
|
|
|
|
|
headers => +{}, |
42
|
|
|
|
|
|
|
protocol => undef, |
43
|
|
|
|
|
|
|
method => $method, |
44
|
|
|
|
|
|
|
%args |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub build_request { |
51
|
8
|
|
|
8
|
0
|
212
|
my ($class, $uri, $body, $args) = @_; |
52
|
|
|
|
|
|
|
|
53
|
8
|
|
|
|
|
31
|
my %req_args = $class->build_request_args( |
54
|
|
|
|
|
|
|
$uri, |
55
|
|
|
|
|
|
|
$body, |
56
|
|
|
|
|
|
|
$args, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
8
|
|
|
|
|
851
|
return HTTP::Engine::Request->new( |
60
|
|
|
|
|
|
|
request_builder => HTTP::Engine::RequestBuilder::NoEnv->new, |
61
|
|
|
|
|
|
|
%req_args, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# This method is used by Interface::Test. |
66
|
|
|
|
|
|
|
sub build_request_args { |
67
|
44
|
|
|
44
|
0
|
2040
|
my($class, $uri, $body, $args) = @_; |
68
|
|
|
|
|
|
|
|
69
|
44
|
100
|
66
|
|
|
579
|
unless (blessed($uri) && $uri->isa('URI')) { |
70
|
4
|
|
|
|
|
21
|
$uri = URI->new( $uri ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return ( |
74
|
|
|
|
|
|
|
uri => URI::WithBase->new( $uri ), |
75
|
44
|
|
50
|
|
|
8598
|
base => do { |
76
|
44
|
|
|
|
|
4257
|
my $base = $uri->clone; |
77
|
44
|
|
|
|
|
642
|
$base->path_query('/'); |
78
|
44
|
|
|
|
|
2298
|
$base; |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
address => '127.0.0.1', |
81
|
|
|
|
|
|
|
port => '80', |
82
|
|
|
|
|
|
|
user => undef, |
83
|
|
|
|
|
|
|
_https_info => undef, |
84
|
|
|
|
|
|
|
_connection => { |
85
|
|
|
|
|
|
|
input_handle => IO::Scalar->new( \( $body ) ), |
86
|
|
|
|
|
|
|
env => ($args->{env} || {}), |
87
|
|
|
|
|
|
|
}, |
88
|
|
|
|
|
|
|
%$args, |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |