I want to have a Go HTTP/2 client for contacting a HTTP/2 supported server using h2c. For which I used Go's http2 transport, but it does not provide options like connection timeout, disable keep-alive, idle connection timeout, etc. as provided by http transport.
I tried using ConfigureTransport function in http2 package but this doesn't work with h2c.
Code snippet which I used is:
protos := []string{"h2", "http/1.1"}
transport1 := &http.Transport{
DisableCompression: !enableCompression,
DisableKeepAlives: !enableKeepAlive,
DialContext: (&net.Dialer{
Timeout: dialTimeout,
}).DialContext,
IdleConnTimeout: idleConnectionTimeout,
MaxIdleConnsPerHost: idleConnectionsPerHost,
TLSClientConfig: &tls.Config{
NextProtos: protos,
},
}
if err := http2.ConfigureTransport(transport1); err != nil {
fmt.Println(err.Error())
}
client := http.Client{
Transport: transport1,
}
resp, err := client.Get("http://<server>/hello.html")
I was expecting communication over h2c to work with all the parameters specified. Am I missing something?