summaryrefslogtreecommitdiffhomepage
path: root/test/perl/variables/psgi.pl
blob: 58232c5340fca3ca397744a821b1fb2eb7b42a47 (plain) (blame)
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
my $app = sub {
    my ($environ) = @_;

    my $len = int($environ->{'CONTENT_LENGTH'});
    $environ->{'psgi.input'}->read(my $body, $len);

    my $version = join('', @{$environ->{'psgi.version'}});

    return ['200', [
        'Content-Type' => $environ->{'CONTENT_TYPE'},
        'Content-Length' => $len,
        'Request-Method' => $environ->{'REQUEST_METHOD'},
        'Request-Uri' => $environ->{'REQUEST_URI'},
        'Http-Host' => $environ->{'HTTP_HOST'},
        'Server-Protocol' => $environ->{'SERVER_PROTOCOL'},
        'Server-Software' => $environ->{'SERVER_SOFTWARE'},
        'Custom-Header' => $environ->{'HTTP_CUSTOM_HEADER'},
        'Psgi-Version' => $version,
        'Psgi-Url-Scheme' => $environ->{'psgi.url_scheme'},
        'Psgi-Multithread' => $environ->{'psgi.multithread'},
        'Psgi-Multiprocess' => $environ->{'psgi.multiprocess'},
        'Psgi-Run-Once' => $environ->{'psgi.run_once'},
        'Psgi-Nonblocking' => $environ->{'psgi.nonblocking'},
        'Psgi-Streaming' => $environ->{'psgi.streaming'}
    ], [$body]];
};