File: localhost.t

package info (click to toggle)
liblwp-protocol-psgi-perl 0.11-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 131; makefile: 2; sh: 1
file content (28 lines) | stat: -rw-r--r-- 606 bytes parent folder | download | duplicates (4)
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
use strict;
use Test::More;
use LWP::UserAgent;
use LWP::Protocol::PSGI;

my $psgi_app = sub { 
    return [
        200,
        [ "Content-Type", "text/plain" ],
        [ "Hi" ],
    ];
};

{
    my $guard = LWP::Protocol::PSGI->register($psgi_app, host => "localhost");
    my $ua  = LWP::UserAgent->new;
    my $res = $ua->get("http://localhost:5000/");
    is $res->content, "Hi";
}

{
    my $guard = LWP::Protocol::PSGI->register($psgi_app, host => "localhost:5000");
    my $ua  = LWP::UserAgent->new;
    my $res = $ua->get("http://localhost:5000/");
    is $res->content, "Hi";
}

done_testing;