File: lf_only_request.t

package info (click to toggle)
starman 0.4017-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 260 kB
  • sloc: perl: 553; makefile: 8
file content (46 lines) | stat: -rw-r--r-- 785 bytes parent folder | download | duplicates (6)
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
use strict;
use warnings;

use Plack::Test;
use HTTP::Request;
use Test::More;

{

    package Starman::Server;

    # override so we can mangle the HTTP request
    use subs 'sysread';

    *Starman::Server::sysread = sub {
        my $read = CORE::sysread( $_[0], $_[1], $_[2] );
        $_[1] =~ s/\r\n/\n/g;

        return $read;
    };

}

$Plack::Test::Impl = "Server";
$ENV{PLACK_SERVER} = 'Starman';

my $app = sub {
    my $env = shift;
    return sub {
        my $response = shift;
        my $writer = $response->( [ 200, [ 'Content-Type', 'text/plain' ] ] );
        $writer->close;
    }
};

test_psgi $app, sub {
    my $cb = shift;

    my $req = HTTP::Request->new( GET => "http://localhost/" );

    my $res = $cb->($req);
    is $res->code, 200;

};

done_testing;