1Net::HTTP::NB(3) User Contributed Perl Documentation Net::HTTP::NB(3)
2
3
4
6 Net::HTTP::NB - Non-blocking HTTP client
7
9 use Net::HTTP::NB;
10 my $s = Net::HTTP::NB->new(Host => "www.perl.com") || die $@;
11 $s->write_request(GET => "/");
12
13 use IO::Select;
14 my $sel = IO::Select->new($s);
15
16 READ_HEADER: {
17 die "Header timeout" unless $sel->can_read(10);
18 my($code, $mess, %h) = $s->read_response_headers;
19 redo READ_HEADER unless $code;
20 }
21
22 while (1) {
23 die "Body timeout" unless $sel->can_read(10);
24 my $buf;
25 my $n = $s->read_entity_body($buf, 1024);
26 last unless $n;
27 print $buf;
28 }
29
31 Same interface as "Net::HTTP" but it will never try multiple reads when
32 the read_response_headers() or read_entity_body() methods are invoked.
33 This make it possible to multiplex multiple Net::HTTP::NB using select
34 without risk blocking.
35
36 If read_response_headers() did not see enough data to complete the
37 headers an empty list is returned.
38
39 If read_entity_body() did not see new entity data in its read the value
40 -1 is returned.
41
43 Net::HTTP
44
46 Copyright 2001 Gisle Aas.
47
48 This library is free software; you can redistribute it and/or modify it
49 under the same terms as Perl itself.
50
51
52
53perl v5.12.4 2008-04-11 Net::HTTP::NB(3)