about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-09-18T09·07+0200
committerEelco Dolstra <edolstra@gmail.com>2017-09-18T09·07+0200
commitaca4f7dff0ee615164668e923deaf5cc96ab1c8a (patch)
treeb15c70471ab332a1dbb86d3698e429179b8ba45c
parent5324bb9399b87782227cc98d83bc3c2d55b102fa (diff)
Don't remove Content-Encoding in fetchurl / nix-prefetch-url
Fixes #1568.
-rw-r--r--src/libstore/builtins.cc1
-rw-r--r--src/libstore/download.cc3
-rw-r--r--src/libstore/download.hh1
-rw-r--r--src/nix-prefetch-url/nix-prefetch-url.cc4
4 files changed, 7 insertions, 2 deletions
diff --git a/src/libstore/builtins.cc b/src/libstore/builtins.cc
index 1075b45c00b5..4ca4a838e3c4 100644
--- a/src/libstore/builtins.cc
+++ b/src/libstore/builtins.cc
@@ -27,6 +27,7 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
            the result anyway. */
         DownloadRequest request(url);
         request.verifyTLS = false;
+        request.decompress = false;
 
         /* Note: have to use a fresh downloader here because we're in
            a forked process. */
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index f5304daeefd2..3f5e744dde19 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -269,7 +269,8 @@ struct CurlDownloader : public Downloader
                 done = true;
 
                 try {
-                    result.data = decodeContent(encoding, ref<std::string>(result.data));
+                    if (request.decompress)
+                        result.data = decodeContent(encoding, ref<std::string>(result.data));
                     callSuccess(success, failure, const_cast<const DownloadResult &>(result));
                     act.progress(result.data->size(), result.data->size());
                 } catch (...) {
diff --git a/src/libstore/download.hh b/src/libstore/download.hh
index 752bf3723cfc..f2d65ad8d61d 100644
--- a/src/libstore/download.hh
+++ b/src/libstore/download.hh
@@ -17,6 +17,7 @@ struct DownloadRequest
     size_t tries = 5;
     unsigned int baseRetryTimeMs = 250;
     ActivityId parentAct;
+    bool decompress = true;
 
     DownloadRequest(const std::string & uri)
         : uri(uri), parentAct(curActivity) { }
diff --git a/src/nix-prefetch-url/nix-prefetch-url.cc b/src/nix-prefetch-url/nix-prefetch-url.cc
index 791a1eeb53cb..7e62a033b458 100644
--- a/src/nix-prefetch-url/nix-prefetch-url.cc
+++ b/src/nix-prefetch-url/nix-prefetch-url.cc
@@ -158,7 +158,9 @@ int main(int argc, char * * argv)
             auto actualUri = resolveMirrorUri(state, uri);
 
             /* Download the file. */
-            auto result = getDownloader()->download(DownloadRequest(actualUri));
+            DownloadRequest req(actualUri);
+            req.decompress = false;
+            auto result = getDownloader()->download(req);
 
             AutoDelete tmpDir(createTempDir(), true);
             Path tmpFile = (Path) tmpDir + "/tmp";