1Net::HTTP::NB(3)      User Contributed Perl Documentation     Net::HTTP::NB(3)
2
3
4

NAME

6       Net::HTTP::NB - Non-blocking HTTP client
7

VERSION

9       version 6.21
10

SYNOPSIS

12        use Net::HTTP::NB;
13        my $s = Net::HTTP::NB->new(Host => "www.perl.com") || die $@;
14        $s->write_request(GET => "/");
15
16        use IO::Select;
17        my $sel = IO::Select->new($s);
18
19        READ_HEADER: {
20           die "Header timeout" unless $sel->can_read(10);
21           my($code, $mess, %h) = $s->read_response_headers;
22           redo READ_HEADER unless $code;
23        }
24
25        while (1) {
26           die "Body timeout" unless $sel->can_read(10);
27           my $buf;
28           my $n = $s->read_entity_body($buf, 1024);
29           last unless $n;
30           print $buf;
31        }
32

DESCRIPTION

34       Same interface as "Net::HTTP" but it will never try multiple reads when
35       the read_response_headers() or read_entity_body() methods are invoked.
36       This make it possible to multiplex multiple Net::HTTP::NB using select
37       without risk blocking.
38
39       If read_response_headers() did not see enough data to complete the
40       headers an empty list is returned.
41
42       If read_entity_body() did not see new entity data in its read the value
43       -1 is returned.
44

SEE ALSO

46       Net::HTTP
47

AUTHOR

49       Gisle Aas <gisle@activestate.com>
50
52       This software is copyright (c) 2001-2017 by Gisle Aas.
53
54       This is free software; you can redistribute it and/or modify it under
55       the same terms as the Perl 5 programming language system itself.
56
57
58
59perl v5.34.0                      2021-07-22                  Net::HTTP::NB(3)
Impressum