File: uc-google.t

package info (click to toggle)
libio-stream-perl 2.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 332 kB
  • sloc: perl: 775; makefile: 7
file content (31 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (3)
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
# Use case: HTTP GET until EOF
use warnings;
use strict;
use lib 't';
use share;

plan skip_all => 'Network connection';

IO::Stream->new({
#    fh          => tcp_client('www.google.com', 80),
    host        => 'www.google.com',
    port        => 80,
    cb          => \&client,
    wait_for    => EOF,
    out_buf     => "GET / HTTP/1.0\nHost: www.google.com\n\n",
    in_buf_limit=> 1024000,
});

@CheckPoint = (
    [ 'client',     EOF, undef      ], 'client: got eof',
);

EV::loop;

sub client {
    my ($io, $e, $err) = @_;
    checkpoint($e, $err);
    like($io->{in_buf}, qr{\AHTTP/\d+\.\d+ }, 'got reply from web server');
    die "server error\n" if $e != EOF || $err;
    EV::unloop;
}