Problem with EOF in LWP library
Gary Howland (gary@systemics.com)
Tue, 18 Jun 1996 13:31:49 +0200
Hi,
I have encountered a few problems with the LWP modules.
The main problem arises due to LWP::Socket::readUntil not detecting EOF.
At line 217 in LWP::Socket.pm:
my $buf = \$self->{'buffer'};
until (length $delim and $$buf =~ /$delim/) {
! my $n = LWP::IO::read($socket, $$buf, $size, length($$buf), $timeout);
+ last if ($n == 0); # EOF
}
if (length $delim) {
I have modified the program to break from the loop if LWP::IO::read
returns zero (EOF).
This then cause a change to be needed in LWP::Protocol::http::request.
At LWP::Protocol::http line 123
my $line;
my $delim = "\015?\012";
my $result = $socket->readUntil($delim, \$line, undef, $timeout);
+ defined $line || return undef;
my $response;
And this in turn caused this change to be required in LWP::UserAgent::simpleRequest.
LWP::UserAgent.pm line 254:
alarm(0) if ($self->useAlarm); # no more timeout
+ unless (defined $response)
+ {
+ $response = new HTTP::Response
+ &HTTP::Status::RC_REQUEST_TIMEOUT,
+ 'connection lost ' .
+ $LWP::Debug::timeoutMessage;
+ $response->request($request); # record request for reference
+ return $response;
+ }
if ($@) {
if ($@ =~ /^timeout/i) {
There is also a problem with the following warning appearing:
Identifier "LWP::IO::bytes_written" used only once: possible typo at (eval 3) line 21.
I made this warning go away by adding this to my programs:
$LWP::IO::bytes_written=666;
However this is obviously not the correct way to fix this problem!
(Note - I am not a member of this list - I would appreciate any followups to
be Cc'ed to me - Thanks).
Gary
--
pub 1024/C001D00D 1996/01/22 Gary Howland <gary@systemics.com>
Key fingerprint = 0C FB 60 61 4D 3B 24 7D 1C 89 1D BE 1F EE 09 06