要害参数:
TLSNextProto
解决方案:
把 TLSNextProto 设置成空 map,这样就不会主动降级,相当于敞开 http2.0
client := &http.Client {
Transport:&http.Transport{TLSNextProto: map[string]func(authority string, c *tls.Conn) http.RoundTripper{},},
}
起因:
来自 https://stackoverflow.com/que…
Starting with Go 1.6, the http package has transparent support for the HTTP/2 protocol when using HTTPS. Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto (for clients) or Server.TLSNextProto (for servers) to a non-nil, empty map. Alternatively, the following GODEBUG environment variables are currently supported: