Don't double-decompress gzipped HTTP responses
authorNicolas Dandrimont <olasd@softwareheritage.org>
Fri, 14 Sep 2018 16:46:54 +0000 (18:46 +0200)
committerNicolas Dandrimont <olasd@softwareheritage.org>
Fri, 14 Sep 2018 16:46:54 +0000 (18:46 +0200)
When using urllib3.response.HTTPResponse's data attribute, decompression of the
response contents is transparent.

Reference: https://forge.softwareheritage.org/T1195
Test-Repository: https://forge.softwareheritage.org/source/helloworld.git

dulwich/client.py

index 254695719b54984d57c0cac30d0523d35bff986c..fc52bcf10df4c56781a7ea35985df1c8b6090baf 100644 (file)
@@ -1435,10 +1435,7 @@ class HttpGitClient(GitClient):
         # `BytesIO`, if we can guarantee that the entire response is consumed
         # before issuing the next to still allow for connection reuse from the
         # pool.
-        if resp.getheader("Content-Encoding") == "gzip":
-            read = gzip.GzipFile(fileobj=BytesIO(resp.data)).read
-        else:
-            read = BytesIO(resp.data).read
+        read = BytesIO(resp.data).read
 
         resp.content_type = resp.getheader("Content-Type")
         resp.redirect_location = resp.get_redirect_location()