From eca401649db970be8fb0df02d126953569ebe91c Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Thu, 9 Feb 2012 21:55:52 +0100 Subject: [PATCH] [entropy.fetchers] UrlFetcher: handle HTTP response without Content-Length It can happen that HTTP servers (or those accessed via Proxy) do not actually provide Content-Length information in the response. This caused UrlFetcher to keep __remotesize = 0, which means that the same thought that the file has been fully downloaded already under some circumstances. --- lib/entropy/fetchers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/entropy/fetchers.py b/lib/entropy/fetchers.py index a60a07738..2a8f5f039 100644 --- a/lib/entropy/fetchers.py +++ b/lib/entropy/fetchers.py @@ -583,7 +583,7 @@ class UrlFetcher(TextInterface): try: self.__remotesize = int(self.__remotefile.headers.get( - "content-length")) + "content-length", -1)) self.__remotefile.close() except KeyboardInterrupt: self.__urllib_close(False) @@ -634,6 +634,9 @@ class UrlFetcher(TextInterface): if self.__remotesize > 0: self.__remotesize = float(int(self.__remotesize))/1024 + else: + # this means we were not able to get Content-Length + self.__remotesize = 0 if url_protocol not in ("file", "ftp", "ftps"): if self.__disallow_redirect and \