http3: add http3 package for testing in std This CL adds an initial http3 package that serves as a thin wrapper over the exported functions in the internal/http3 package. Doing so allows us to import and vendor the HTTP/3 implementation in x/net from std. This will be used to run std tests against our HTTP/3 implementation. To prevent users from unexpectedly using this package, only unexported symbols have been added to the package, with linkname that only allows them to be used by the net/http_test package in std. For golang/go#70914 Change-Id: I6b420bb1eb07fd86174ee4c1ede43ef26a6a6964 Reviewed-on: https://go-review.googlesource.com/c/net/+/762041 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Nicholas Husin <husin@google.com>
diff --git a/http3/http3.go b/http3/http3.go new file mode 100644 index 0000000..72ac090 --- /dev/null +++ b/http3/http3.go
@@ -0,0 +1,31 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package http3 + +import ( + "net/http" + _ "unsafe" // for linkname + + . "golang.org/x/net/internal/http3" + "golang.org/x/net/quic" +) + +//go:linkname registerHTTP3Server net/http_test.registerHTTP3Server +func registerHTTP3Server(s *http.Server) <-chan string { + listenAddr := make(chan string) + RegisterServer(s, ServerOpts{ + ListenQUIC: func(addr string, config *quic.Config) (*quic.Endpoint, error) { + e, err := quic.Listen("udp", addr, config) + listenAddr <- e.LocalAddr().String() + return e, err + }, + }) + return listenAddr +} + +//go:linkname registerHTTP3Transport net/http_test.registerHTTP3Transport +func registerHTTP3Transport(tr *http.Transport) { + RegisterTransport(tr) +}