File: mk-chunked-response.pl

package info (click to toggle)
libfurl-perl 3.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 660 kB
  • sloc: perl: 2,188; makefile: 5; sh: 1
file content (31 lines) | stat: -rw-r--r-- 667 bytes parent folder | download | duplicates (4)
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
#!perl -w
use strict;
use Furl;
use Plack::Loader;
use Child;

{
    package Furl::Verbose;
    use parent qw(Furl);
    sub read_timeout {
        my $self = shift;
        my $ret  = $self->SUPER::read_timeout(@_);
        print ${$_[1]};
        return $ret;
    }
}

my $content = "The quick brown fox jumps over the lazy dog.\n" x 100;

my $child = Child->new(
    sub {
        Plack::Loader->load('Starman', host => '127.0.0.1', port => 1234 )
          ->run(
            sub { [ 200, ['Transfer-Encoding' => 'chunked' ], [$content] ] } );
    }
);
my $proc = $child->start();
sleep 1;
Furl::Verbose->new->get('http://127.0.0.1:1234/');
$proc->kill('TERM');