IO::Lambda::HTTP::http_request should return an HTTP::Reponse object.
The returned object claims to be that type, but it doesn't support the
base method of HTTP::Reponse.
I get this error:
njh@packard:~/src/njh$ ./lambda3
example: 438 bytes
Use of uninitialized value in print at ./lambda3 line 21 (#1)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
To help you figure out what was undefined, perl will try to tell you the
name of the variable (if any) that was undefined. In some cases it
cannot
do this, so it also tells you what operation you used the undefined
value
in. Note, however, that perl optimizes your program and the operation
displayed in the warning may not necessarily appear literally in your
program. For example, "that $foo" is usually optimized into "that "
. $foo, and the warning will refer to the concatenation (.) operator,
even though there is no . in your program.
base:
njh@packard:~/src/njh$
From this program:
njh@packard:~/src/njh$ cat lambda3
#!/usr/bin/perl -wT
use strict;
use warnings;
use diagnostics;
use HTTP::Request;
use IO::Lambda qw(:lambda);
use IO::Lambda::HTTP qw(http_request);
lambda {
context(
HTTP::Request-> new(GET => '
http://www.example.com/'),
async_dns => 1,
keep_alive => 1,
proxy => [ '192.168.1.1', '3128' ],
);
http_request {
my $res = shift;
if ( ref($res) and ref($res) eq 'HTTP::Response') {
print "example: ", length($res-> content), " bytes\n";
print "base: ", $res->base, "\n";
} else {
print "example: error :$res\n";
}
}
}-> wait;
njh@packard:~/src/njh$