[ create a new paste ] login | about

Link: http://codepad.org/531qBASm    [ raw code | fork ]

Perl, pasted on Jun 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# $ starman app.psgi
use strictures;
use autodie q(:all);
use Time::HiRes qw(sleep);
open my $h, '<:raw', 'the.pdf';

my $app = sub {
    my $env = shift;
    return sub {
        my $respond = shift;
        my $writer = $respond->([200, ['Content-Type' => 'application/pdf']]);
        my $buf;
        while (sysread($h, $buf, 1024)) {
            $writer->write($buf);
            sleep 0.02;
        }
        $writer->close;
    };
};


Create a new paste based on this one


Comments: