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?

-Dom
--- 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;

Reply via email to