net/http: doc: Clarify that Server.ServeTLS enables http2, but Server.Serve does not #46602
Labels
Documentation
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?1.16.5
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?amd64 linux
What did you expect to see?
I expected that
Server.Serve
would support http2 when I provided it with my customer listener. My expectation was based on this statement in the documentation:After a full day of trying to debug this issue I found out that only
Server.ServeTLS
(and the functions that call it) supports http2 because it makes sure to fix thetls.Config
by (smartly) adding the default protocols.Server.Serve
does not, because of course it does not have access to anytls.Config
.For those interested, here is a one-liner workaround when creating your listener:
I'm not sure what the best way to fix the documentation would be! But I think it should state that:
Server.Serve
does not support http2 by default and even suggest my one-liner above as a workaround.The above blanket statement about "transparent support" should also be modified with specifics on which codepaths enable http2.
The text was updated successfully, but these errors were encountered: