http3: rework registration to allow using a fake network This is the x/net half of a paired set of changes which modify the mechanism by which x/net/http3 integrates with net/http. The other half of the change is CL 803380. x/net/http3 exports two functions via linkname for use by net/http's tests. These are now: registerServer(*http.Server, opts any) error registerTransport(*http.Transport, opts any) error These are now thin wrappers around the interal/http3 registration functions, with a bit of reflection-based struct copying to permit passing in options without exporting the options types. (The end state is for these functions to be exported and take exported options types.) Server registration no longer uses TLSNextProto. Instead, the HTTP/3 server registers itself via net/http.Server.Serve, which is the same approach used by x/net/http2. This gives us a simpler link between the two packages. For example, net/http can just call a Shutdown method on the HTTP/3 server and pass it a Context, rather than the prior complex dance. The HTTP/3 server no longer calls net.Listen. It always accepts a net.PacketConn from net/http. TransportOpts now has a ListenPacket field, in addition to ListenQUIC. Server and Transport now both accept their *tls.Configs from net/http. net/http is responsible for correctly configuring NextProtos. This makes TLS config construction more consistent overall, since net/http already sets up the HTTP/1 and HTTP/2 configs. These changes simplify the registration machinery in some places, but mainly permit us to now pass a fake net.PacketConn from net/http's tests into the http package. As part of this change, the HTTP/3 server's handler and base context are now per-endpoint rather than per-server. net/http Servers permit setting a per-net.Listener base context for request handlers. Treating the HTTP/3 base context as per-endpoint maintains the equivalent ability. Making the handler per-endpoint isn't strictly necessary, but is consistent with the context and simplifies the connection between net/http and x/net/http3. For golang/go#80480 Change-Id: I10d6e998c11cade33e517d1d2f03a2d86a6a6964 Reviewed-on: https://go-review.googlesource.com/c/net/+/801940 Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This repository holds supplementary Go networking packages.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.
The git repository is https://go.googlesource.com/net.
The main issue tracker for the net repository is located at https://go.dev/issues. Prefix your issue with “x/net:” in the subject line, so it is easy to find.