I'm trying to understand why in the following code, client2 doesn't work 'http2_handshake_failed" error)
thx
...
package main
import (
"crypto/tls"
"fmt"
"net/http"
"time"
)
func main() {
// client1, disable HTTP/2
httpClient1 := &http.Client{
Transport: &http.Transport{
TLSNextProto: map[string]func(string, *tls.Conn) http.RoundTripper{},
},
}
// client2, clone default transport, disable HTTP/2
var netTransport = http.DefaultTransport.(*http.Transport).Clone()
netTransport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}
netTransport.ForceAttemptHTTP2 = false
httpClient2 := &http.Client{
Transport: netTransport,
}
doClient(httpClient1)
doClient(httpClient2)
}
func doClient(client *http.Client) {
resp, err := client.Get("
https://google.com/")
if err != nil {
fmt.Printf("client error : %s\n", err)
} else {
defer resp.Body.Close()
fmt.Printf("Response status: %s with protocol %s\n", resp.Status, resp.Proto)
}
}
...