Re: Need help on LWP::UserAgent module!
Bill Moseley (moseley@hank.org)
Tue, 14 Nov 2000 15:49:27 -0800
At 03:36 PM 11/14/00 -0800, Gisle Aas wrote:
>> Maybe there's a better way, but this is what I do to validate a URL:
>>
>> $req = HTTP::Request->new( GET => $url );
>> $ua->timeout( $LWP_GET_WAIT || 30 );
>> $res = $ua->simple_request( $req, sub { die }, 100 );
>
>The same effect can also be achieved with:
>
> $req = HTTP::Request->new( GET => $url );
> $ua->timeout( $LWP_GET_WAIT || 30 );
> $ua->max_size( 1 );
> $res = $ua->simple_request( $req );
if ($max_size && $content_size > $max_size) {
LWP::Debug::debug("Aborting because size limit exceeded");
my $tot = $response->header("Content-Length") || 0;
response->header("X-Content-Range", "bytes 0-$content_size/$tot");
last;
}
This looks like the same thing, I see.
I wish I understood this better -- and I'm sure my question will show that!
Is the socket closed at that point? And is there any delay waiting for the
connection to be closed on the other end? If I do this quickly for a lot
of requests will I end up with a lot of CLOSE_WAIT sockets?
My goal, of course, is to get the first chunk back from the remote server,
and then move on with as little waiting as possible.
Thanks,
Bill Moseley
mailto:moseley@hank.org