man-pages/man3/Net::HTTP::NB.3pm.html
2021-03-31 01:06:50 +01:00

115 lines
2.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Net::HTTP::NB</TITLE>
</HEAD><BODY>
<H1>Net::HTTP::NB</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-07-18<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Net::HTTP::NB - Non-blocking HTTP client
<A NAME="lbAC">&nbsp;</A>
<H2>VERSION</H2>
version 6.19
<A NAME="lbAD">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
use Net::HTTP::NB;
my $s = Net::HTTP::NB-&gt;new(Host =&gt; &quot;<A HREF="http://www.perl.com">www.perl.com</A>&quot;) || die $@;
$s-&gt;write_request(GET =&gt; &quot;/&quot;);
use IO::Select;
my $sel = IO::Select-&gt;new($s);
READ_HEADER: {
die &quot;Header timeout&quot; unless $sel-&gt;can_read(10);
my($code, $mess, %h) = $s-&gt;read_response_headers;
redo READ_HEADER unless $code;
}
while (1) {
die &quot;Body timeout&quot; unless $sel-&gt;can_read(10);
my $buf;
my $n = $s-&gt;read_entity_body($buf, 1024);
last unless $n;
print $buf;
}
</PRE>
<A NAME="lbAE">&nbsp;</A>
<H2>DESCRIPTION</H2>
Same interface as <TT>&quot;Net::HTTP&quot;</TT> but it will never try multiple reads
when the <B>read_response_headers()</B> or <B>read_entity_body()</B> methods are
invoked. This make it possible to multiplex multiple Net::HTTP::NB
using select without risk blocking.
<P>
If <B>read_response_headers()</B> did not see enough data to complete the
headers an empty list is returned.
<P>
If <B>read_entity_body()</B> did not see new entity data in its read
the value -1 is returned.
<A NAME="lbAF">&nbsp;</A>
<H2>SEE ALSO</H2>
Net::HTTP
<A NAME="lbAG">&nbsp;</A>
<H2>AUTHOR</H2>
Gisle Aas &lt;<A HREF="mailto:gisle@activestate.com">gisle@activestate.com</A>&gt;
<A NAME="lbAH">&nbsp;</A>
<H2>COPYRIGHT AND LICENSE</H2>
This software is copyright (c) 2001-2017 by Gisle Aas.
<P>
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">VERSION</A><DD>
<DT id="3"><A HREF="#lbAD">SYNOPSIS</A><DD>
<DT id="4"><A HREF="#lbAE">DESCRIPTION</A><DD>
<DT id="5"><A HREF="#lbAF">SEE ALSO</A><DD>
<DT id="6"><A HREF="#lbAG">AUTHOR</A><DD>
<DT id="7"><A HREF="#lbAH">COPYRIGHT AND LICENSE</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:49 GMT, March 31, 2021
</BODY>
</HTML>