From 96cec8023f5a22777e4e8f3defe6b399afb7faa6 Mon Sep 17 00:00:00 2001 From: Bernd Gollesch Date: Sat, 2 Jul 2016 11:34:01 +0200 Subject: [PATCH] Always try to get the length. --- transfers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/transfers.py b/transfers.py index 8d120744..23ebb734 100644 --- a/transfers.py +++ b/transfers.py @@ -128,12 +128,10 @@ def download( req.raise_for_status() encoding = req.headers.get('content-encoding', 'uncompress') + length = req.headers.get('content-length', None) transfer = req.headers.get('transfer-encoding', None) - if transfer == 'chunked': + if transfer != 'chunked': # chunked transfer-encoding doesn't need a content-length - length = None - else: - length = req.headers.get('content-length', None) if length is None: raise Exception("Remote server replied with invalid content-length.") length = int(length)