Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: x/net/http2: Add ConfigureTransportWithOptions function #41721

caesarxuchao opened this issue Sep 30, 2020 · 4 comments

proposal: x/net/http2: Add ConfigureTransportWithOptions function #41721

caesarxuchao opened this issue Sep 30, 2020 · 4 comments


Copy link

@caesarxuchao caesarxuchao commented Sep 30, 2020

http2.ConfigureTranport configures a net/http HTTP/1 Transport to use HTTP/2, but it does not allow setting http2 specific configurations, e.g., ReadIdleTimeout and PingTimeout. See end-user issue #40201.

The proposal is that adding a ConfigureTransportWithOptions function, which takes a TransportOptions as an input to configure http2 specific configurations.

golang/net#74 is an implementation of this proposal.

@gopherbot gopherbot added this to the Proposal milestone Sep 30, 2020
@gopherbot gopherbot added the Proposal label Sep 30, 2020
@ianlancetaylor ianlancetaylor added this to Incoming in Proposals Oct 14, 2020
Copy link

@neild neild commented Oct 20, 2020

I don't think we need an entirely new representation of HTTP/2 transport configuration; the *http2.Transport type already exposes all the necessary configuration fields. The problem is that http2.ConfigureTransport doesn't provide any way to get at the *http2.Transport it creates.

I propose instead:

package http2

// ConfigureTransports configures a net/http HTTP/1 Transport to use HTTP/2.
// It returns a new HTTP/2 Transport for further configuration.
// It returns an error if t1 has already been HTTP/2-enabled.
func ConfigureTransports(t1 *http.Transport) (*Transport, error) { ... }

Having ConfigureTransport and ConfigureTransports functions with almost identical names is unfortunate, but the two will sort next to each other in godoc and the difference between the two is obvious from the function signature.

Copy link

@gopherbot gopherbot commented Oct 20, 2020

Change mentions this issue: x/net/http2: add ConfigureTransports

Copy link

@caesarxuchao caesarxuchao commented Oct 21, 2020

That's a good solution! Thanks, @neild.

At first I was concerned that with this solution, the user won't be able to configure the http2 transport (t2) that's registered as the upgrade handler of t1, but then I realized that t2 is a pointer, so the user can just modify the t2 that's returned by ConfigureTransports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.