xref: /unit/test/perl/input_buffered_read/psgi.pl (revision 2060:a1991578c62e)
1*2060Smax.romanov@nginx.comuse FileHandle;
2*2060Smax.romanov@nginx.com
3*2060Smax.romanov@nginx.commy $app = sub {
4*2060Smax.romanov@nginx.com    my ($environ) = @_;
5*2060Smax.romanov@nginx.com
6*2060Smax.romanov@nginx.com    $environ->{'psgi.input'}->read(my $body, 1024);
7*2060Smax.romanov@nginx.com
8*2060Smax.romanov@nginx.com    open my $io, "<", \$body;
9*2060Smax.romanov@nginx.com
10*2060Smax.romanov@nginx.com    # This makes $io work as FileHandle under 5.8, .10 and .11.
11*2060Smax.romanov@nginx.com    bless $io, 'FileHandle';
12*2060Smax.romanov@nginx.com
13*2060Smax.romanov@nginx.com    $environ->{'psgix.input.buffered'} = 1;
14*2060Smax.romanov@nginx.com    $environ->{'psgi.input'} = $io;
15*2060Smax.romanov@nginx.com
16*2060Smax.romanov@nginx.com    return ['200', ['Content-Length' => length $body], [$body]];
17*2060Smax.romanov@nginx.com};
18