LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent::Entry=HASH(0xe0f768) [http://www.cnn.com] )
LWP::Parallel::UserAgent::on_connect: (http://www.cnn.com)
LWP::Parallel::UserAgent::_connect: (LWP::Parallel::UserAgent::Entry=HASH(0xe0f768) [http://www.cnn.com] )
LWP::Parallel::UserAgent::init_request: -> (HTTP::Request=HASH(0xa0c23c)) [GET http://www.cnn.com]
LWP::Parallel::UserAgent::init_request: GET http://www.cnn.com
LWP::UserAgent::_need_proxy: Not proxied
LWP::Parallel::UserAgent::on_failure: (http://www.cnn.com)
LWP::Parallel::UserAgent::_check_bandwith: Failed connection for 'www.cnn.com:80
'
####
1) LWP::Parallel::UserAgent::_check_bandwith: (LWP::Parallel::UserAgent::Entry=HASH(0xe0f768) [http://www.cnn.com] )
2) LWP::Parallel::UserAgent::on_connect: (http://www.cnn.com)
3) LWP::Parallel::UserAgent::_connect: (LWP::Parallel::UserAgent::Entry=HASH(0xe0f768) [http://www.cnn.com] )
4) LWP::Parallel::UserAgent::init_request: -> (HTTP::Request=HASH(0xa0c23c)) [GET http://www.cnn.com]
5) LWP::Parallel::UserAgent::init_request: GET http://www.cnn.com
6) LWP::UserAgent::_need_proxy: Not proxied
7) LWP::Parallel::UserAgent::on_failure: (http://www.cnn.com)
8) LWP::Parallel::UserAgent::_check_bandwith: Failed connection for 'www.cnn.com:80
'
# this method checks the available bandwith and either connects
# the request and returns 1, or, in case we didn't have enough
# bandwith, returns undef
sub _check_bandwith {
my ( $self, $entry ) = @_;
#1 LWP::Debug::trace("($entry [".$entry->request->url."] )");
.....
} elsif ( $self->_hosts_available ) {
#2 $self->on_connect ( $request, $response, $entry );
#3 unless ( $self->_connect ( $entry ) ) {
# only increase connection count if _connect doesn't return error
$self->{'current_connections'}->{$netloc}++;
} else {
# calling ->on_failure is done within ->_connect
#8 LWP::Debug::debug ("Failed connection for '" . $netloc ."'");
$self->{'failed_connections'}->{$netloc}++;
.....
}
sub _connect {
my ($self, $entry) = @_;
#3 LWP::Debug::trace("($entry [".$entry->request->url."] )");
local($SIG{"__DIE__"}); # protect against user defined die handlers
my ( $request, $response ) = $entry->get( qw(request response) );
my ($error_response, $proxy, $protocol, $timeout, $use_eval, $nonblock) =
#4 $self->init_request ($request);
if ($error_response) {
# we need to manually set code and message of $response as well, so
# that we have the correct information in our $entry as well
$response->code ($error_response->code);
$response->message ($error_response->message);
#7 $self->on_failure ($request, $error_response, $entry);
return $error_response;
}
####
} elsif ( $self->_hosts_available ) {
$self->on_connect ( $request, $response, $entry );
my $err_msg = $self->_connect ( $entry );
unless ( $err_msg ) {
# only increase connection count if _connect doesn't return error
$self->{'current_connections'}->{$netloc}++;
} else {
# calling ->on_failure is done within ->_connect
LWP::Debug::debug ("Failed connection for '" . $netloc ."'\nError: $err_msg");
$self->{'failed_connections'}->{$netloc}++;