bug in libwww-perl-5.05
Willi Burmeister (wib@cs.uni-kiel.de)
Tue, 21 Jan 1997 09:03:25 +0100 (MET)
Hi,
I think there is a bug in libwww-perl-5.05. Just try to make
a HEAD Request on
http://www.informatik.uni-kiel.de/
and
http://www.netuse.de/
The first works ok, but the second gives an "Unexpected EOF"
Here the output while doing HTTP by hand
------------------------------------------------------------
eden{wib} telnet www.informatik.uni-kiel.de 80
Trying 134.245.252.14...
Connected to falbala.informatik.uni-kiel.de.
Escape character is '^]'.
HEAD / HTTP/1.0
HTTP/1.0 200 OK
Server: Spinner
Content-type: text/html
Last-Modified: Tue, 14 Jan 1997 17:23:27 +0000
Date: Mon, 20 Jan 1997 12:55:07 +0000
Content-length: 2499
Connection closed by foreign host.
------------------------------------------------------------
------------------------------------------------------------
eden{wib} telnet www.netuse.de 80
Trying 193.98.110.18...
Connected to www.netuse.de.
Escape character is '^]'.
HEAD / HTTP/1.0
HTTP/1.0 200 OK
MIME-Version: 1.0
Date: Mon, 20 Jan 1997 12:54:54 GMT
Server: phttpd/0.99.73c-rk-pl1.2
Last-Modified: Thu, 02 Jan 1997 13:25:48 GMT
Content-Type: text/html
Content-Length: 3882
Connection closed by foreign host.
------------------------------------------------------------
'www.informatik.uni-kiel.de' sends an empty last line.
'www.netuse.de' does not. I checked the RFC and I think this
behavior is legal. So the bug is in 'LWP/Protocol/http.pm'
line 132:
my $result = $socket->read_until("\015?\012\015?\012", \$header,
undef, $timeout);
The Documentation of 'read_until' tells us:
'If $delim is undefined all data is read'
So I changed the call to:
my $result = $socket->read_until(undef, \$header,
undef, $timeout);
But then we get errors from 'read_until'. Checking '$delim'
is coming too late.
Here my patches for this bug:
------------------------------------------------------------
eden{gnu} diff -c Socket.pm.ori Socket.pm
*** Socket.pm.ori Fri Jun 21 17:52:52 1996
--- Socket.pm Mon Jan 20 14:15:16 1997
***************
*** 210,215 ****
--- 210,217 ----
{
my ($self, $delim, $data_ref, $size, $timeout) = @_;
+ $delim = '' unless defined $delim;
+
{
my $d = $delim;
$d =~ s/\r/\\r/g;
***************
*** 218,224 ****
}
my $socket = $self->{'socket'};
- $delim = '' unless defined $delim;
$size ||= $self->{'size'};
my $buf = \$self->{'buffer'};
--- 220,225 ----
------------------------------------------------------------
and
------------------------------------------------------------
eden{gnu} diff -c http.pm.ori http.pm
*** http.pm.ori Mon Oct 28 19:10:40 1996
--- http.pm Mon Jan 20 14:12:02 1997
***************
*** 129,135 ****
LWP::Debug::debug('reading rest of response header');
my $header = '';
! my $result = $socket->read_until("\015?\012\015?\012", \$header,
undef, $timeout);
# now entire header is read, parse it
--- 129,135 ----
LWP::Debug::debug('reading rest of response header');
my $header = '';
! my $result = $socket->read_until(undef, \$header,
undef, $timeout);
# now entire header is read, parse it
------------------------------------------------------------
Willi