Re: [patch] Negative Content-Length
am 07.12.2005 11:04:43 von gisleDominic Mitchell
> I've got a problem with an Apache server serving up files with a
> negative Content-Length header (because the file is over 2Gb).
>
> Unfortunately, it causes LWP to not download the file at all.
>
> I'd like to propose this small change to be allow :read_size_hint to
> be used if the Content-Length is negative. It seems to be sensible to
> me as a way of allowing the problem to be worked around.
>
> Does the patch look reasonable?
No, I don't find it reasonable, as this is not what :read_size_hint is
documented to do.
One possibilty is to simly ignore a Content-Length header with a
negative value. This would mean that everything that comes on the
socket until EOF is regarded the message content. I've implemented
that for LWP-5.805.
--Gisle
> --- lib/Net/HTTP/Methods.pm.orig 2005-08-02 17:39:40.775697019 +0100
> +++ lib/Net/HTTP/Methods.pm 2005-08-02 17:26:35.000000000 +0100
> @@ -479,7 +479,7 @@
> return 0;
> }
> my $n = $bytes;
> - $n = $size if $size && $size < $n;
> + $n = $size if $size && ($n < 0 || $size < $n);
> $n = my_read($self, $$buf_ref, $n);
> return undef unless defined $n;
> ${*$self}{'http_bytes'} = $bytes - $n;