Blob Blame History Raw
From 6a582f49fa958e4ba3e374d0e77d814524111dfb Mon Sep 17 00:00:00 2001
From: Miro HronĨok <miro@hroncok.cz>
Date: Jan 23 2021 13:15:35 +0000
Subject: Use Accept-Encoding: identity together with decode_content=False


This should fix both the issues:

 - gzips decompressed: https://pagure.io/rpmdevtools/issue/72
 - texts compressed: https://pagure.io/rpmdevtools/issue/76

    $ file tor-0.4.5.4-rc.tar.gz tor-0.4.5.4-rc.tar.gz.asc xrootd-5.0.3.tar.gz
    tor-0.4.5.4-rc.tar.gz:     gzip compressed data, max compression, from Unix, original size modulo 2^32 35962880
    tor-0.4.5.4-rc.tar.gz.asc: PGP signature Signature (old)
    xrootd-5.0.3.tar.gz:       gzip compressed data, max compression, from Unix, original size modulo 2^32 981462405

---

diff --git a/rpmdev-spectool b/rpmdev-spectool
index 56a2d43..a324fab 100755
--- a/rpmdev-spectool
+++ b/rpmdev-spectool
@@ -239,6 +239,9 @@ def download(url, target, headers=None, tracker: Optional[ProgressTracker] = Non
         headers = {}
 
     headers.setdefault("User-Agent", "rpmdev-spectool")
+    # identity should prevent servers from sending gzip-compressed text
+    # which would later not be decompressed because we set decode_content=False
+    headers.setdefault("Accept-Encoding", "identity")
 
     ret = requests.get(url, headers=headers, stream=True)
     ret.raise_for_status()