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

This commit is contained in:
Nick Craig-Wood 2021-04-19 17:00:07 +01:00
parent 8bef972262
commit 9e6c23d9af
3 changed files with 6 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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)