i'm trying to use http client to connect in http/2 clear text (H2C).
this works:

var dialer = &net.Dialer{
Timeout: 5 * time.Second, // fail quick
FallbackDelay: -1, // don't use Happy Eyeballs
}
rt = &http2.Transport{
AllowHTTP: true,
DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) {
return dialer.Dial(network, addr)
},
}
....
rt.RoundTrip(some request)

but this doesn't:

// same dialer
var netTransport = http.DefaultTransport.(*http.Transport).Clone()
netTransport.DialContext = dialer.DialContext
var rt http.RoundTripper = netTransport
rt2, err := http2.ConfigureTransports(netTransport)
if err != nil {
log.Fatal(err)
}
rt2.AllowHTTP = true
....
rt.RoundTrip(some request)

complete code at: 
https://github.com/nspeed-app/http2issue/blob/main/main.go#L199

what am I missing ?
how to get a common transport that can do http/1.1, h2c and http/2 ?


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/226b86a5-ee9a-4ec6-97c9-3758ce5cf42bn%40googlegroups.com.

Reply via email to