diff options
author | Georg Brandl <georg@python.org> | 2014-11-06 14:33:30 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-11-06 14:33:30 (GMT) |
commit | 72a7f7c476841dde6977f099cc63807df5858c2d (patch) | |
tree | 3d2dc18b04fe092b728f030f2b3aa5144cf9e0a0 | |
parent | 5a15508f978c1d6fd3f87b26c8c3605222b38f1a (diff) | |
download | cpython-72a7f7c476841dde6977f099cc63807df5858c2d.zip cpython-72a7f7c476841dde6977f099cc63807df5858c2d.tar.gz cpython-72a7f7c476841dde6977f099cc63807df5858c2d.tar.bz2 |
Try to transfer the Unicode test data files gzipped.
-rw-r--r-- | Lib/test/support/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index a64ed56..e6db70f 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -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() |