line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Test::Server; |
2
|
10
|
|
|
10
|
|
62
|
use strict; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
278
|
|
3
|
10
|
|
|
10
|
|
44
|
use warnings; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
249
|
|
4
|
10
|
|
|
10
|
|
45
|
use Carp; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
635
|
|
5
|
10
|
|
|
10
|
|
566
|
use HTTP::Request; |
|
10
|
|
|
|
|
16575
|
|
|
10
|
|
|
|
|
342
|
|
6
|
10
|
|
|
10
|
|
4317
|
use HTTP::Response; |
|
10
|
|
|
|
|
59349
|
|
|
10
|
|
|
|
|
404
|
|
7
|
10
|
|
|
10
|
|
4900
|
use Test::TCP; |
|
10
|
|
|
|
|
609946
|
|
|
10
|
|
|
|
|
761
|
|
8
|
10
|
|
|
10
|
|
5070
|
use Plack::Loader; |
|
10
|
|
|
|
|
31
|
|
|
10
|
|
|
|
|
305
|
|
9
|
10
|
|
|
10
|
|
3983
|
use Plack::LWPish; |
|
10
|
|
|
|
|
31
|
|
|
10
|
|
|
|
|
2325
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
11
|
|
|
11
|
0
|
42
|
my($class, $app, %args) = @_; |
13
|
|
|
|
|
|
|
|
14
|
11
|
|
50
|
|
|
73
|
my $host = $args{host} || '127.0.0.1'; |
15
|
|
|
|
|
|
|
my $server = Test::TCP->new( |
16
|
|
|
|
|
|
|
listen => $args{listen}, |
17
|
|
|
|
|
|
|
host => $host, |
18
|
|
|
|
|
|
|
code => sub { |
19
|
0
|
|
|
0
|
|
0
|
my $sock_or_port = shift; |
20
|
|
|
|
|
|
|
my $server = Plack::Loader->auto( |
21
|
|
|
|
|
|
|
($args{listen} ? ( |
22
|
0
|
0
|
|
|
|
0
|
listen_sock => $sock_or_port, |
23
|
|
|
|
|
|
|
):( |
24
|
|
|
|
|
|
|
port => $sock_or_port, |
25
|
|
|
|
|
|
|
host => $host, |
26
|
|
|
|
|
|
|
)) |
27
|
|
|
|
|
|
|
); |
28
|
0
|
|
|
|
|
0
|
$server->run($app); |
29
|
0
|
|
|
|
|
0
|
exit; |
30
|
|
|
|
|
|
|
}, |
31
|
11
|
|
|
|
|
121
|
); |
32
|
|
|
|
|
|
|
|
33
|
11
|
|
|
|
|
533499
|
bless { server => $server, %args }, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub port { |
37
|
15
|
|
|
15
|
0
|
139
|
my $self = shift; |
38
|
15
|
|
|
|
|
4633
|
$self->{server}->port; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub request { |
42
|
15
|
|
|
15
|
0
|
69
|
my($self, $req) = @_; |
43
|
|
|
|
|
|
|
|
44
|
15
|
|
33
|
|
|
530
|
my $ua = $self->{ua} || Plack::LWPish->new( no_proxy => [qw/127.0.0.1/] ); |
45
|
|
|
|
|
|
|
|
46
|
15
|
|
|
|
|
93
|
$req->uri->scheme('http'); |
47
|
15
|
|
50
|
|
|
27165
|
$req->uri->host($self->{host} || '127.0.0.1'); |
48
|
15
|
|
|
|
|
2124
|
$req->uri->port($self->port); |
49
|
|
|
|
|
|
|
|
50
|
15
|
|
|
|
|
1094
|
return $ua->request($req); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |