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

x/net/http2: rename and export Transport's t1 field #16581

Open
mna opened this issue Aug 3, 2016 · 6 comments
Open

x/net/http2: rename and export Transport's t1 field #16581

mna opened this issue Aug 3, 2016 · 6 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mna
Copy link

mna commented Aug 3, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

    go version go1.7rc4 darwin/amd64

  2. What operating system and processor architecture are you using (go env)?

    GOARCH="amd64"
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"

  3. What did you do?

    Directly use an http2.Transport to set its AllowHTTP field to true, to enable HTTP/2 over HTTP (and set DialTLS accordingly, as mentioned here: x/net/http2: support h2c for http2 #14141 (comment)).

  4. What did you expect to see?

    Have access to the same rich set of configuration options as are available on http.Transport.

  5. What did you see instead?

    Many configuration options from http.Transport are not available on http2.Transport (e.g. controlling idle connections in the ClientConnPool).

As discussed on golang-dev mailing list (https://groups.google.com/forum/#!topic/golang-dev/HmqDsLpTywk), as it currently stands, if we have to directly use the http2.Transport, we have to give up on a number of configuration options that are present only on http.Transport. @bradfitz suggested to rename and export the http2.Transport.t1 field to fix this.

@nathany
Copy link
Contributor

nathany commented Aug 12, 2016

👍

I'm currently pulling in x/net/http2 just to call http2.ConfigureTransport with a custom certificate for an HTTP/2 client. It would be lovely if I could cause the standard library to use HTTP/2 instead. This is the code that I currently use x/net/http2 for:

// NewClient sets up an HTTP/2 client for a certificate.
func NewClient(cert tls.Certificate) (*http.Client, error) {
    config := &tls.Config{
        Certificates: []tls.Certificate{cert},
    }
    config.BuildNameToCertificate()
    transport := &http.Transport{TLSClientConfig: config}

    if err := http2.ConfigureTransport(transport); err != nil {
        return nil, err
    }

    return &http.Client{Transport: transport}, nil
}

@bradfitz
Copy link
Contributor

Nathan, how is that related to this bug?

@nathany
Copy link
Contributor

nathany commented Aug 12, 2016

Sorry @bradfitz. I thought it was related and that I may not be the only one wanting to use net/http directly for HTTP/2 even when configuration changes are necessary. Guess I misread the forum discussion.

@bradfitz
Copy link
Contributor

@nathany, per #14275 and other bugs, we've decided that we're going to stay out of people's way who are doing custom things with their configuration. There's nothing wrong with importing "golang.org/x/net/http2" to wire up an abnormal configuration.

This bug is about giving more control to people who are already importing golang.org/x/net/http2.

@pwaller
Copy link
Contributor

pwaller commented Sep 20, 2016

There's nothing wrong with importing "golang.org/x/net/http2" to wire up an abnormal configuration

Is this documented somewhere? After a search, your comment was the only thing I could really find that says it explicitly. https://golang.org/pkg/net/http/ says nothing about HTTP2 being disabled if you specify a TLSClientConfig. Can we get a way to enable HTTP2 and specify a TLSClientConfig without requiring the external dependency? If my request is reasonable I am happy to create a separate issue.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 5, 2016
@quentinmit
Copy link
Contributor

Since this doesn't affect http2 as used in the release, I'm moving this to the Unreleased milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants