Skip to content

Commit

Permalink
Always try to get the length.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgol committed Jul 2, 2016
1 parent 89ef16e commit 96cec80
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 96cec80

Please sign in to comment.