Commit 59d45d94 authored by Jason R. Coombs's avatar Jason R. Coombs

Support get_headers on Python 3 and Python 2

parent 8f52bc5f
...@@ -608,7 +608,10 @@ class PackageIndex(Environment): ...@@ -608,7 +608,10 @@ class PackageIndex(Environment):
size = -1 size = -1
if "content-length" in headers: if "content-length" in headers:
# Some servers return multiple Content-Length headers :( # Some servers return multiple Content-Length headers :(
size = max(map(int,headers.getheaders("Content-Length"))) if not hasattr(headers, 'get_all'):
# Older versions of Python don't have the get_all method
headers.get_all = headers.getheaders
size = max(map(int,headers.get_all("Content-Length")))
self.reporthook(url, filename, blocknum, bs, size) self.reporthook(url, filename, blocknum, bs, size)
tfp = open(filename,'wb') tfp = open(filename,'wb')
while True: while True:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment