At 09:34 AM 04/23/01 -0700, Gisle Aas wrote:
> Keep-alive and the new HTTP/1.1 module can now be simply
> enabled with something like:
>
> LWP::UserAgent->new(keep_alive => 1);
Humm, my mind isn't working. Do (can) you have a kepp_alive method to
set/get that value.
The problem is I'm using LWP::RobotUA, and I think its new() doesn't pass
the parameters to LWP::UserAgent when creating the ua object.
In other words, how do I turn on keep_alives with RobotUA?
And now (_91) LWP::UserAgent does the require on http11 so I don't need to
load it in my code as in then _90 version, correct?
In my code I was wrapping the require http11 in an eval block so I could
fallback to non-keep alives if the require on http11 failed (I assumed not
everyone that will be using my code will have a current LWP with
keep_alives enabled).
I assume old versions of LWP (without keep_alive support) will just ignore
that passed-in parameter. My old code using the eval { require http11 }
would warn to upgrade their copy of LWP.
Can I continue to use the _90 method, or is there a better way?
if ( $server->{keep_alive} ) {
eval 'require LWP::Protocol::http11;';
if ( $@ ) {
warn "Cannot use keep alives, please upgrade LWP -- $@\n";
} else {
LWP::Protocol::implementor('http', 'LWP::Protocol::http11');
}
} else {
require LWP::Protocol::http;
LWP::Protocol::implementor('http', 'LWP::Protocol::http');
}
And for picking which module, I do this:
if ( $server->{ignore_robots_file} ) {
$ua = LWP::UserAgent->new();
return unless $ua;
$ua->agent( $server->{agent} );
$ua->from( $server->{email} );
} else {
$ua = LWP::RobotUA->new( $server->{agent}, $server->{email} );
return unless $ua;
$ua->delay( $server->{delay_min} || 0.1 );
}
Bill Moseley
mailto:[EMAIL PROTECTED]