英文:
How do I set MaxConnsPerHost on http2 transport in GoLang
问题
我正在尝试强制GoLang使用HTTP2,并进行了以下操作:
transport := &http2.Transport{}
client := &http.Client{Transport: transport}
但我还需要设置MaxConnsPerHost和MaxIdleConns,但我无法设置它们。我知道在HTTP1中可以按以下方式设置它们:
transport := &http.Transport{
MaxIdleConns: 0,
MaxIdleConnsPerHost: 1000,
}
httpClient := &http.Client{Transport: transport}
我该如何在HTTP2中实现相同的效果?
英文:
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?
答案1
得分: 0
回答我自己的问题:正如Peter指出的那样,这不适用于HTTP2。
英文:
Answering my own question here: As Peter pointed out, this would not apply to HTTP2.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论