[go] net/http: rework HTTP/3 registration to allow using a fake network

1 view
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jul 23, 2026, 5:42:48 PM (3 days ago) Jul 23
to Damien Neil, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Nicholas Husin, Nicholas Husin, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: src/net/http/clientserver_test.go
Insertions: 0, Deletions: 1.

@@ -239,7 +239,6 @@
}
})
case mode == http3Mode:
- // TODO: support testing HTTP/3 using fakenet.
cst.ts = &httptest.Server{
Config: &Server{Handler: h},
}
```
```
The name of the file: src/net/http/http3.go
Insertions: 6, Deletions: 1.

@@ -34,10 +34,15 @@
func (c http3PacketConn) Addr() net.Addr { return c.conn.LocalAddr() }

func (s *Server) serveHTTP3(conn net.PacketConn, certFile, keyFile string) error {
- baseCtx := context.WithValue(context.Background(), ServerContextKey, s)
+ baseCtx := context.Background()
if s.BaseContext != nil {
+ // The Server.BaseContext hook receives a net.Listener.
+ // For HTTP/3 connections, provide it with a Listener that has the same Addr
+ // as the PacketConn we're actually serving from.
baseCtx = s.BaseContext(http3PacketConn{conn})
}
+ baseCtx = context.WithValue(baseCtx, ServerContextKey, s)
+
tlsConfig, err := s.setupTLSConfig(certFile, keyFile, []string{"h3"})
if err != nil {
return err
```

Change information

Commit message:
net/http: rework HTTP/3 registration to allow using a fake network

This is the net/http 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 801940. See that CL for a more
in-depth description of the change.

This change drops support for HTTP/3 in ListenAndServeTLS (for now).
Tests use ServeTLS instead.
Change-Id: If6fcea4be6638a4670477c6472e480476a6a6964
Reviewed-by: Nicholas Husin <hu...@google.com>
Reviewed-by: Nicholas Husin <n...@golang.org>
Auto-Submit: Damien Neil <dn...@google.com>
Files:
  • M src/net/http/clientserver_test.go
  • A src/net/http/http3.go
  • M src/net/http/httptest/server.go
  • M src/net/http/server.go
  • M src/net/http/transport.go
Change size: L
Delta: 5 files changed, 200 insertions(+), 109 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: If6fcea4be6638a4670477c6472e480476a6a6964
Gerrit-Change-Number: 803380
Gerrit-PatchSet: 4
Gerrit-Owner: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Nicholas Husin <hu...@google.com>
Gerrit-Reviewer: Nicholas Husin <n...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages