1 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 # corner case tests for the generic PSGI server
4 # Usage: plackup [OPTIONS] /path/to/this/file
11 my $path = $env->{PATH_INFO};
12 my $in = $env->{'psgi.input'};
15 my $h = [ 'Content-Type' => 'text/plain' ];
17 if ($path eq '/sha1') {
18 my $sha1 = Digest::SHA->new('SHA-1');
21 my $r = $in->read($buf, 4096);
22 die "read err: $!" unless defined $r;
27 push @$body, $sha1->hexdigest;
28 } elsif (my $fifo = $env->{HTTP_X_CHECK_FIFO}) {
29 if ($path eq '/slow-header') {
31 open my $f, '<', $fifo or
32 die "open $fifo: $!\n";
34 $_[0]->([200, $h, \@r ]);
36 } elsif ($path eq '/slow-body') {
38 my $fh = $_[0]->([200, $h]);
39 open my $f, '<', $fifo or
40 die "open $fifo: $!\n";
41 while (defined(my $l = <$f>)) {
47 } elsif ($path eq '/host-port') {
49 push @$body, "$env->{REMOTE_ADDR}:$env->{REMOTE_PORT}";
50 } elsif ($path eq '/callback') {
53 my $buf = "hello world\n";
54 push @$h, 'Content-Length', length($buf);
55 my $fh = $res->([200, $h]);
65 enable 'ContentLength';