gohttp2http-1.1go-http

How do I set MaxConnsPerHost on http2 transport in GoLang


I'm trying to force GoLang to use HTTP2 and so have done the following:

transport := &http2.Transport{}
client := &http.Client{Transport: transport}

But I also need to set MaxConnsPerHost and MaxIdleConns, which I'm not able to. I know I can set them in HTTP1 as follows:

transport := &http.Transport{
    MaxIdleConns: 0,
    MaxIdleConnsPerHost: 1000,
}
httpClient := &http.Client{Transport: transport}

How can I achieve the same for HTTP2?


Solution

  • Answering my own question here: As Peter pointed out, this would not apply to HTTP2.