File: 06_long_resp.t

package info (click to toggle)
libanyevent-httpd-perl 0.93-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 244 kB
  • sloc: perl: 1,247; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 828 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
32
33
#!perl
use common::sense;
use Test::More tests => 2;
use AnyEvent::Impl::Perl;
use AnyEvent;
use AnyEvent::HTTPD;
use AnyEvent::Socket;

my $h = AnyEvent::HTTPD->new;

my $SEND = "ELMEXBLABLA1235869302893095934";#"ABCDEF" x 1024;
my $SENT = $SEND;

$h->reg_cb (
   '/test' => sub {
      my ($httpd, $req) = @_;
      $req->respond ({
         content => ['text/plain', sub {
            my ($data_cb) = @_;
            return unless $data_cb;
            $data_cb->(substr $SENT, 0, 10, '');
         }]
      });
   },
);

my $c = AnyEvent::HTTPD::Util::test_connect ('127.0.0.1', $h->port,
           "GET\040http://localhost:19090/test\040HTTP/1.0\015\012\015\012");
my $buf = $c->recv;

$buf =~ s/^.*?\015?\012\015?\012//s;
ok (length ($buf) == length ($SEND), 'sent all data');
ok (length ($SENT) == 0, 'send buf empty');