From 277d94feac563e2c3a64c16e77cbe63ef88d63f8 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 9 Jan 2020 14:00:46 +0000 Subject: [PATCH] fshttp: add --expect-continue-timeout default 1s - fixes #3835 Before this change the expect/continue timeout was set to --conntimeout which was 60s by default which is too long to wait. This was noticed when using s3 with a proxy which apparently didn't support expect / continue properly. Set --expect-continue-timeout 0 to disable expect/continue. --- docs/content/docs.md | 13 +++++++++++++ fs/config.go | 2 ++ fs/config/configflags/configflags.go | 1 + fs/fshttp/http.go | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/content/docs.md b/docs/content/docs.md index f2cf1d72e..02dc47f4b 100644 --- a/docs/content/docs.md +++ b/docs/content/docs.md @@ -539,6 +539,19 @@ Do a trial run with no permanent changes. Use this to see what rclone would do without actually doing it. Useful when setting up the `sync` command which deletes files in the destination. +### --expect-continue-timeout=TIME ### + +This specifies the amount of time to wait for a server's first +response headers after fully writing the request headers if the +request has an "Expect: 100-continue" header. Not all backends support +using this. + +Zero means no timeout and causes the body to be sent immediately, +without waiting for the server to approve. This time does not include +the time to send the request header. + +The default is `1s`. Set to 0 to disable. + ### --ignore-case-sync ### Using this option will cause rclone to ignore the case of the files diff --git a/fs/config.go b/fs/config.go index b497ac7dd..54675ffab 100644 --- a/fs/config.go +++ b/fs/config.go @@ -54,6 +54,7 @@ type ConfigInfo struct { Transfers int ConnectTimeout time.Duration // Connect timeout Timeout time.Duration // Data channel timeout + ExpectContinueTimeout time.Duration Dump DumpFlags InsecureSkipVerify bool // Skip server certificate verification DeleteMode DeleteMode @@ -121,6 +122,7 @@ func NewConfig() *ConfigInfo { c.Transfers = 4 c.ConnectTimeout = 60 * time.Second c.Timeout = 5 * 60 * time.Second + c.ExpectContinueTimeout = 1 * time.Second c.DeleteMode = DeleteModeDefault c.MaxDelete = -1 c.LowLevelRetries = 10 diff --git a/fs/config/configflags/configflags.go b/fs/config/configflags/configflags.go index 3ae0cbf64..16ad272d9 100644 --- a/fs/config/configflags/configflags.go +++ b/fs/config/configflags/configflags.go @@ -50,6 +50,7 @@ func AddFlags(flagSet *pflag.FlagSet) { flags.BoolVarP(flagSet, &fs.Config.DryRun, "dry-run", "n", fs.Config.DryRun, "Do a trial run with no permanent changes") flags.DurationVarP(flagSet, &fs.Config.ConnectTimeout, "contimeout", "", fs.Config.ConnectTimeout, "Connect timeout") flags.DurationVarP(flagSet, &fs.Config.Timeout, "timeout", "", fs.Config.Timeout, "IO idle timeout") + flags.DurationVarP(flagSet, &fs.Config.ExpectContinueTimeout, "expect-continue-timeout", "", fs.Config.ExpectContinueTimeout, "Timeout when using expect / 100-continue in HTTP") flags.BoolVarP(flagSet, &dumpHeaders, "dump-headers", "", false, "Dump HTTP headers - may contain sensitive info") flags.BoolVarP(flagSet, &dumpBodies, "dump-bodies", "", false, "Dump HTTP headers and bodies - may contain sensitive info") flags.BoolVarP(flagSet, &fs.Config.InsecureSkipVerify, "no-check-certificate", "", fs.Config.InsecureSkipVerify, "Do not verify the server SSL certificate. Insecure.") diff --git a/fs/fshttp/http.go b/fs/fshttp/http.go index db1face8b..1414426be 100644 --- a/fs/fshttp/http.go +++ b/fs/fshttp/http.go @@ -178,7 +178,7 @@ func NewTransportCustom(ci *fs.ConfigInfo, customize func(*http.Transport)) http return dialContextTimeout(ctx, network, addr, ci) } t.IdleConnTimeout = 60 * time.Second - t.ExpectContinueTimeout = ci.ConnectTimeout + t.ExpectContinueTimeout = ci.ExpectContinueTimeout // customize the transport if required if customize != nil {