pass a context to Transport.ConnContext (#4536)

* pass a context to Transport.ConnContext

This context is cancelled when the QUIC connection is closed, or when
the QUIC handshake fails. This allows the application to easily build
and garbage collect a map of active connections.

* correctly handle fresh contexts returned from ConnContext
This commit is contained in:
Marten Seemann
2024-06-05 12:37:18 +08:00
committed by GitHub
parent 07acaad2f7
commit 44e0147f2e
7 changed files with 114 additions and 35 deletions

View File

@@ -600,9 +600,9 @@ var _ = Describe("HTTP tests", func() {
defer conn.Close()
tr := &quic.Transport{
Conn: conn,
ConnContext: func() context.Context {
ConnContext: func(ctx context.Context) context.Context {
//nolint:staticcheck
return context.WithValue(context.Background(), "foo", "bar")
return context.WithValue(ctx, "foo", "bar")
},
}
defer tr.Close()