On Tue, Aug 25, 2009 at 07:02:58PM -0400, Daniel Richard G. wrote:
> On Tue, 2009 Aug 25 21:13+0100, Mark Hindley wrote:
> >
> > > But what about servers that don't return Content-Length even for
> > > successful requests?
> >
> > This is difficult. I don't think it can have happened really, as I
> > notice return_file() relies on Content-Length being set to initialise
> > $explen. It would blow up without that.
> >
> > This is my solution. It isn't very elegant, but I think it covers
> > the issue.
> 
> Something's not right here. "-s $$pkfdref" returns 0 for a number of
> real files, "apt-get update" spews "Bad header line" errors (because
> files are being returned with "Content-Length: 0"), and then very oddly,
> it goes into a loop where it downloads dists/lenny/non-free/binary-
> i386/Packages.bz2 over and over and over again. I tried replacing -s
> with sysseek($$pkfdref, 0, 1), but same result.

I think this is a buffering issue.

I can fix it here, and get the right size with the patch below. The
other alternative is to use autoflush on $$pkfdref. I need to do some
testing to see if that is a better option.

Mark

commit 4b0946018c0176eba7111031ed6bd54beef9117d
Author: Mark Hindley <m...@hindley.org.uk>
Date:   Wed Aug 26 11:19:32 2009 +0100

    Need to flush $$pkfdref to get correct size. Is this the real fix?

diff --git a/apt-cacher b/apt-cacher
index 23664dc..c3cd031 100755
--- a/apt-cacher
+++ b/apt-cacher
@@ -1355,6 +1355,7 @@ sub libcurl {
        if ($pkfdref && $response && !defined $response->content_length) {
            # Must be HTTP 1.0 server upstream
            info_message('Header output delayed whilst getting Content-Length');
+           $$pkfdref->flush();
            $response->content_length(-s $$pkfdref);
            &write_header(\$response);
        }



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to