Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
IO::Lambda::HTTP(3)   User Contributed Perl Documentation  IO::Lambda::HTTP(3)

       IO::Lambda::HTTP	- http requests	lambda style

       The module exports a single condition "http_request" that accepts a
       "HTTP::Request" object and set of options as parameters.	The condition
       returns either a	"HTTP::Response" on success, or	an error string

	  use HTTP::Request;
	  use IO::Lambda qw(:all);
	  use IO::Lambda::HTTP qw(http_request);

	  lambda {
	     context shift;
	     http_request {
		my $result = shift;
		if ( ref($result)) {
		   print "good:	", length($result-> content), "	bytes\n";
		} else {
		   print "bad: $result\n";
	  }-> wait(
	      HTTP::Request-> new( GET => "")

       http_request $HTTP::Request -> $HTTP::Response
	   "http_request" is a lambda condition	that accepts "HTTP::Request"
	   object in the context. Returns either a "HTTP::Response" object on
	   success, or error string otherwise.

       new $HTTP::Request :: ()	-> $HTTP::Response
	   Stores "HTTP::Request" object and returns a new lambda that will
	   finish when the associated request completes. The lambda will
	   return either a "HTTP::Response" object on success, or an error
	   string otherwise.

       async_dns BOOLEAN
	   If set, hostname will be resolved with IO::Lambda::DNS using
	   asynchronous	capabilities of	Net::DNS. Note that this method	won't
	   be able to account for non-DNS (/etc/hosts, NIS) host names.

	   If unset (default), hostnames will be resolved in a blocking

       auth $AUTH
	   Normally, a request is sent without any authentication. If the
	   request returns error 401, then all available methods of
	   authentication are tried. If	the type of authentication that	shall
	   be accepted by the remote is	known in advance, the non-
	   authenticated request stage can be skipped altogether by explicitly
	   setting the "auth" option:

	      username => 'user',
	      password => 'pass',
	      auth     => 'Basic',

       conn_cache $LWP::ConnCache = undef
	   The requestor can optionally	use a "LWP::ConnCache" object to reuse
	   connections on per-host per-port basis. Desired for HTTP/1.1.
	   Required for	the NTLM/Negotiate authentication.  See	LWP::ConnCache
	   for details.

       deadline	SECONDS	= undef
	   Aborts a request and	returns	'timeout' string as an error if	the
	   request is not finished before the deadline (in epoch seconds). If
	   undef, timeout never	occurs.

       keep_alive BOOLEAN
	   If set, all incoming	request	objects	are silently converted use
	   HTTP/1.1, and connections are automatically reused. Same as
	   combination of the following:

	      $req-> protocol('HTTP/1.1');
	      $req-> headers-> header( Host => $req-> uri-> host);
	      new( $req, conn_cache => LWP::ConnCache->	new);

       max_redirect NUM	= 7
	   Maximum allowed redirects. If 0, no redirection attemps are made.

       preferred_auth $AUTH|%AUTH
	   Sets	list of	preferred authentication methods, that is used in
	   selection of	the authentication method when the remote server
	   supports several. When the value is a string, then the given	method
	   is tried first, and only then all other available methods. When it
	   is a	hash, the hash values are treated as weight factors, such as,
	   the method with the greatest	weight is tried	first. Negative	values
	   prevent the corresponding methods from being	tried.

		# try basic and	whatever else
		preferred_auth => 'Basic',

		# try basic and	never ntlm
		preferred_auth => {
		    Basic => 1,
		    NTLM  => -1,

	   Note	that the current implementation	does not provide re-trying of
	   authentication if a method, or combination of username and password
	   fails.  When	at least one method is declared	by the remote as
	   supported, and was tried, and subsequently failed, no further
	   authentication retries are made, and	the request is reported	as

       proxy HOSTNAME |	[ HOSTNAME, PORT ]
	   If set, HOSTNAME (or	HOSTNAME and PORT tuple) is used as HTTP

       timeout SECONDS = undef
	   Maximum allowed time	the request can	take. If undef,	no timeouts

       Non-blocking connects, and hence	the module, don't work on win32	on
       perl5.8.X due to	under-implementation in	ext/IO.xs.  They do work on
       5.10 however.

       IO::Lambda, HTTP::Request, HTTP::Response

       Dmitry Karasik, <>.

perl v5.32.0			  2012-03-14		   IO::Lambda::HTTP(3)


Want to link to this manual page? Use this URL:

home | help