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

net/http: document when a Transport will not automatically upgrade to a HTTP/2 Transport #17296

noblehng opened this issue Sep 30, 2016 · 1 comment


Copy link

@noblehng noblehng commented Sep 30, 2016

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7.1 linux/amd64

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


What did you do?

I'm trying to pinning a TLS cert for a HTTP/2 server, so I have a custom http.Transport with its TLSClientConfig set like:

 TLSClientConfig: &tls.Config{
     RootCAs:    pool,
     NextProtos: []string{"h2", "http/1.1"},

What did you expect to see?

From current documentation, TLSNextProto is nil, so the transport should be upgraded to HTTP/2 automatically and the request to the server should success.

What did you see instead?

The request failed with:

http2: server: error reading preface from client bogus greeting "GET / HTTP/1.1\r\nHost: 12"

It still use a http/1.1 transport after negotiated for h2.

It turns out that after the change with #14275, if either TLSClientConfig or Dial or DialTLS is set for a http.Transport, the automatically upgrade will not happen. But the current documentation of http.Transport doesn't mention this.

@bradfitz bradfitz added this to the Go1.8 milestone Sep 30, 2016
@quentinmit quentinmit added the NeedsFix label Oct 7, 2016
Copy link

@gopherbot gopherbot commented Nov 10, 2016

CL mentions this issue.

@gopherbot gopherbot closed this in caa434d Nov 10, 2016
@golang golang locked and limited conversation to collaborators Nov 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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