-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: HTTP version selection API #67814
Comments
My initial proposal for this in #60746 configured protocols with an ordered I'm not sure about the use of a bitmask to represent sets of protocols. It's simple and we're unlikely to ever run out of 64 bits, but perhaps it's a bit too simple? We could have an opaque type instead:
|
This proposal has been added to the active column of the proposals project |
Does it have to be so general at all? An even more pedestrian API would be: type Protocols struct { ... } It's not as cute but it doesn't paint us into any corners and it's very clear. Thoughts? |
Looks good to me. |
Have all remaining concerns about this proposal been addressed? The proposal is to add a new copyable type
and then have both Server and Transport add a new field Protocols Protocols that sets which protocols can be used. The default if no protocols are set will be whatever the package deems appropriate. |
Based on the discussion above, this proposal seems like a likely accept. The proposal is to add a new copyable type
and then have both Server and Transport add a new field Protocols Protocols that sets which protocols can be used. The default if no protocols are set will be whatever the package deems appropriate. |
No change in consensus, so accepted. 🎉 The proposal is to add a new copyable type
and then have both Server and Transport add a new field Protocols Protocols that sets which protocols can be used. The default if no protocols are set will be whatever the package deems appropriate. |
Change https://go.dev/cl/607496 mentions this issue: |
I've implemented this in CL 607496. Implementation turned up a couple subtleties to the API: Minor: The accepted proposal uses a pointer receiver for the accessor methods ( More significant: Let's say you have an
This doesn't always work, however. If I think that either the zero valued One possibility is to make
Another might be to make
Or maybe we could go back to the very original version of this design and make the
|
Perhaps:
Now if the user calls An alternative might be to unexport Server.Protocols and Transport.Protocols in favor of accessors (Server.SetProtocols, etc.), but currently Server and Transport have many exported configuration fields and no unexported ones. We could live with the inconsistency, but I'd much prefer to keep the Protocols field exported. |
Can we expand the documentation on |
Change https://go.dev/cl/635335 mentions this issue: |
For #67814 Change-Id: I182e9c7e720493adb9d2384336e757dace818525 Reviewed-on: https://go-review.googlesource.com/c/go/+/635335 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Damien Neil <[email protected]> Reviewed-by: Austin Clements <[email protected]>
This issue is part of a project to move
x/net/http2
intostd
: #67810I propose adding a new mechanism for selecting what HTTP versions will be used by a
net/http
Server
orTransport
.Currently, by default
net/http
server listening on a TLS connection will accept both HTTP/1 and HTTP/2 requests;net/http
transport will use HTTP/1 for https requests (never HTTP/2); andnet/http.DefaultTransport
will use HTTP/2 when available and HTTP/1 otherwise for https requests.Users may disable HTTP/2 support by setting
Server.TLSNextProto
orTransport.TLSNextProto
to an empty map.Users may enable HTTP/2 support on a transport by setting
Transport.ForceAttemptHTTP2
.Users may disable HTTP/1 support by importing
golang.org/x/net/http2
using anhttp2.Server
orhttp2.Transport
directly.The net/http package does not currently directly support HTTP/3, but if and when it does, there will need to be a mechanism for enabling or disabling HTTP/3.
The existing APIs for selecting a protocol version are confusing, inconsistent, expose internal implementation details, and don't generalize well to additional protocol versions. The above proposal replaces them with a single, clear mechanism that allows for future expansion.
Example usage:
The text was updated successfully, but these errors were encountered: