Index: Lib/http/client.py =================================================================== --- Lib/http/client.py (revision 86667) +++ Lib/http/client.py (working copy) @@ -71,6 +71,7 @@ import io import os import socket +import gzip from urllib.parse import urlsplit import warnings @@ -491,6 +492,10 @@ self.close() return b"" + if self.getheader('Content-Encoding') == 'gzip': + self.fp = gzip.GzipFile(fileobj=self.fp, mode='rb') + self.length = None + if self.chunked: return self._read_chunked(amt) Index: Lib/urllib/request.py =================================================================== --- Lib/urllib/request.py (revision 86676) +++ Lib/urllib/request.py (working copy) @@ -1084,6 +1084,10 @@ headers = dict(req.unredirected_hdrs) headers.update(dict((k, v) for k, v in req.headers.items() if k not in headers)) + hasAcceptEncoding = ("Accept-Encoding" in headers or + "Accept-encoding" in headers) + if not hasAcceptEncoding: + headers["Accept-Encoding"] = "gzip" # TODO(jhylton): Should this be redesigned to handle # persistent connections?