From dfc7cd97a3fb714c05eae6966448b8839a76efa4 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 14 Feb 2016 18:14:41 +0000 Subject: [PATCH] Optionally disable gzip compression on downloads with `--no-gzip-encoding` - fixes #353 --- docs/content/docs.md | 10 ++++++++++ fs/config.go | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/docs/content/docs.md b/docs/content/docs.md index e2602d19a..30cfd2dee 100644 --- a/docs/content/docs.md +++ b/docs/content/docs.md @@ -392,6 +392,16 @@ if you are reading and writing to an OS X filing system this will be This command line flag allows you to override that computed default. +### --no-gzip-encoding ### + +Don't set `Accept-Encoding: gzip`. This means that rclone won't ask +the server for compressed files automatically. Useful if you've set +the server to return files with `Content-Encoding: gzip` but you +uploaded compressed files. + +There is no need to set this in normal operation, and doing so will +decrease the network transfer efficiency of rclone. + ### -q, --quiet ### Normally rclone outputs stats and a completion message. If you set diff --git a/fs/config.go b/fs/config.go index 80134cfdf..bbea2e32d 100644 --- a/fs/config.go +++ b/fs/config.go @@ -82,6 +82,7 @@ var ( deleteAfter = pflag.BoolP("delete-after", "", false, "When synchronizing, delete files on destination after transfering") lowLevelRetries = pflag.IntP("low-level-retries", "", 10, "Number of low level retries to do.") updateOlder = pflag.BoolP("update", "u", false, "Skip files that are newer on the destination.") + noGzip = pflag.BoolP("no-gzip-encoding", "", false, "Don't set Accept-Encoding: gzip.") bwLimit SizeSuffix // Key to use for password en/decryption. @@ -201,6 +202,7 @@ type ConfigInfo struct { DeleteAfter bool // Delete after successful transfer. LowLevelRetries int UpdateOlder bool // Skip files that are newer on the destination + NoGzip bool // Disable compression } // Transport returns an http.RoundTripper with the correct timeouts @@ -235,6 +237,16 @@ func (ci *ConfigInfo) Transport() http.RoundTripper { // In this mode, TLS is susceptible to man-in-the-middle attacks. // This should be used only for testing. TLSClientConfig: &tls.Config{InsecureSkipVerify: ci.InsecureSkipVerify}, + + // DisableCompression, if true, prevents the Transport from + // requesting compression with an "Accept-Encoding: gzip" + // request header when the Request contains no existing + // Accept-Encoding value. If the Transport requests gzip on + // its own and gets a gzipped response, it's transparently + // decoded in the Response.Body. However, if the user + // explicitly requested gzip it is not automatically + // uncompressed. + DisableCompression: *noGzip, } if ci.DumpHeaders || ci.DumpBodies { return NewLoggedTransport(t, ci.DumpBodies) @@ -291,6 +303,7 @@ func LoadConfig() { Config.InsecureSkipVerify = *skipVerify Config.LowLevelRetries = *lowLevelRetries Config.UpdateOlder = *updateOlder + Config.NoGzip = *noGzip ConfigPath = *configFile