Try to transfer the Unicode test data files gzipped.

This commit is contained in:
Georg Brandl 2014-11-06 15:33:30 +01:00
parent 5a15508f97
commit 72a7f7c476
1 changed files with 6 additions and 1 deletions

View File

@ -1029,7 +1029,12 @@ def open_urlresource(url, *args, **kw):
requires('urlfetch')
print('\tfetching %s ...' % url, file=get_original_stdout())
f = urllib.request.urlopen(url, timeout=15)
opener = urllib.request.build_opener()
if gzip:
opener.addheaders.append(('Accept-Encoding', 'gzip'))
f = opener.open(url, timeout=15)
if gzip and f.headers.get('Content-Encoding') == 'gzip':
f = gzip.GzipFile(fileobj=f)
try:
with open(fn, "wb") as out:
s = f.read()