Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fs: add --disable-http2 for global http2 disable #5253

Nick Craig-Wood9e6c23d9af99
diff --git a/fs/config.go b/fs/config.go
index 0e3ce187d..eece951f8 100644
--- a/fs/config.go
+++ b/fs/config.go
@@ -125,6 +125,7 @@ type ConfigInfo struct {
TrafficClass uint8
FsCacheExpireDuration time.Duration
FsCacheExpireInterval time.Duration
+ DisableHTTP2 bool
}
// NewConfig creates a new config with everything set to the default
diff --git a/fs/config/configflags/configflags.go b/fs/config/configflags/configflags.go
index 7a00c14f1..62098835b 100644
--- a/fs/config/configflags/configflags.go
+++ b/fs/config/configflags/configflags.go
@@ -130,6 +130,7 @@ func AddFlags(ci *fs.ConfigInfo, flagSet *pflag.FlagSet) {
flags.StringVarP(flagSet, &dscp, "dscp", "", "", "Set DSCP value to connections. Can be value or names, eg. CS1, LE, DF, AF21.")
flags.DurationVarP(flagSet, &ci.FsCacheExpireDuration, "fs-cache-expire-duration", "", ci.FsCacheExpireDuration, "cache remotes for this long (0 to disable caching)")
flags.DurationVarP(flagSet, &ci.FsCacheExpireInterval, "fs-cache-expire-interval", "", ci.FsCacheExpireInterval, "interval to check for expired remotes")
+ flags.BoolVarP(flagSet, &ci.DisableHTTP2, "disable-http2", "", ci.DisableHTTP2, "Disable HTTP/2 in the global transport.")
}
// ParseHeaders converts the strings passed in via the header flags into HTTPOptions
diff --git a/fs/fshttp/http.go b/fs/fshttp/http.go
index fb8e6945d..b2b72bb99 100644
--- a/fs/fshttp/http.go
+++ b/fs/fshttp/http.go
@@ -100,6 +100,10 @@ func NewTransportCustom(ctx context.Context, customize func(*http.Transport)) ht
" the body of the request will be gunzipped before showing it.")
}
+ if ci.DisableHTTP2 {
+ t.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}
+ }
+
// customize the transport if required
if customize != nil {
customize(t)