This file is indexed.

/usr/share/perl5/Plack/Test/Server.pm is in libplack-perl 1.0047-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package Plack::Test::Server;
use strict;
use warnings;
use Carp;
use HTTP::Request;
use HTTP::Response;
use Test::TCP;
use Plack::Loader;
use Plack::LWPish;

sub new {
    my($class, $app, %args) = @_;

    my $host = $args{host} || '127.0.0.1';
    my $server = Test::TCP->new(
        listen => $args{listen},
        host => $host,
        code => sub {
            my $sock_or_port = shift;
            my $server = Plack::Loader->auto(
                ($args{listen} ? (
                    listen_sock => $sock_or_port,
                ):(
                    port => $sock_or_port,
                    host => $host,
                ))
            );
            $server->run($app);
            exit;
        },
    );

    bless { server => $server, %args }, $class;
}

sub port {
    my $self = shift;
    $self->{server}->port;
}

sub request {
    my($self, $req) = @_;

    my $ua = $self->{ua} || Plack::LWPish->new( no_proxy => [qw/127.0.0.1/] );

    $req->uri->scheme('http');
    $req->uri->host($self->{host} || '127.0.0.1');
    $req->uri->port($self->port);

    return $ua->request($req);
}

1;

__END__

=head1 NAME

Plack::Test::Server - Run HTTP tests through live Plack servers

=head1 DESCRIPTION

Plack::Test::Server is a utility to run PSGI application with Plack
server implementations, and run the live HTTP tests with the server
using a callback. See L<Plack::Test> how to use this module.

=head1 AUTHOR

Tatsuhiko Miyagawa

Tokuhiro Matsuno

=head1 SEE ALSO

L<Plack::Loader> L<Test::TCP> L<Plack::Test>

=cut