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: Server.ServeTLS docs are wrong about H/2 #24607

FiloSottile opened this issue Mar 30, 2018 · 2 comments

net/http: Server.ServeTLS docs are wrong about H/2 #24607

FiloSottile opened this issue Mar 30, 2018 · 2 comments


Copy link

@FiloSottile FiloSottile commented Mar 30, 2018

For HTTP/2 support, srv.TLSConfig should be initialized to the provided listener's TLS Config before calling ServeTLS. If srv.TLSConfig is non-nil and doesn't include the string "h2" in Config.NextProtos, HTTP/2 support is not enabled.

Since ServeTLS gets to create the tls.Listener, it can initialize the TLSConfig fully, and it does. So the second paragraph is wrong. (Probably because it was copied from Serve #23028.)

Also, ListenAndServeTLS doesn't mention H/2 at all, but applies the same rules as ServeTLS.

The rules are pretty messy, probably worth reviewing all [Server.][ListenAnd]Serve[TLS] docs.

See also #22018

@FiloSottile FiloSottile added this to the Go1.11 milestone Mar 30, 2018
Copy link

@gopherbot gopherbot commented Mar 30, 2018

Change mentions this issue: net/http: fix and normalize the [Server.][ListenAnd]Serve[TLS] docs

Copy link

@gopherbot gopherbot commented Jul 23, 2018

Change mentions this issue: net/http: update Serve docs on when HTTP/2 is enabled

@gopherbot gopherbot closed this in 214f7ec Jul 23, 2018
gopherbot pushed a commit that referenced this issue Jul 24, 2018
The only inaccurate part was the HTTP/2 caveat in Server.ServeTLS, which
only applies to the plain Serve variant.

The restriction implemented in shouldConfigureHTTP2ForServe is not on
the setupHTTP2_ServeTLS codepath because ServeTLS owns the tls.Listener,
so we fix it for the user instead of disabling HTTP/2.

Fixes #24607

Change-Id: Ie5f207d0201f09db27bf81b75535e5f6fdaf91e2
Reviewed-by: Brad Fitzpatrick <>
@golang golang locked and limited conversation to collaborators Jul 23, 2019
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
2 participants
You can’t perform that action at this time.