Skip to content

Commit

Permalink
use a context
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 5, 2024
1 parent dd1367a commit 692ecdc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions http3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type SingleDestinationRoundTripper struct {
// It is invalid to specify any settings defined by RFC 9114 (HTTP/3) and RFC 9297 (HTTP Datagrams).
AdditionalSettings map[uint64]uint64

SignalValues map[uint64]func(quic.Stream)
UniStreamType map[uint64]func(quic.ReceiveStream)
SignalValues map[uint64]func(context.Context, quic.Stream)
UniStreamType map[uint64]func(context.Context, quic.ReceiveStream)

// MaxResponseHeaderBytes specifies a limit on how many response bytes are
// allowed in the server's response header.
Expand Down Expand Up @@ -122,7 +122,7 @@ func (c *SingleDestinationRoundTripper) handleBidirectionalStreams() {
}
return
}
var hijack func(quic.Stream)
var hijack func(context.Context, quic.Stream)
fp := &frameParser{
r: str,
conn: c.hconn,
Expand All @@ -141,7 +141,7 @@ func (c *SingleDestinationRoundTripper) handleBidirectionalStreams() {
}
}
if hijack != nil {
hijack(str)
hijack(c.Connection.Context(), str)
return
}
c.hconn.CloseWithError(quic.ApplicationErrorCode(ErrCodeFrameUnexpected), "received HTTP/3 frame on bidirectional stream")
Expand Down
4 changes: 2 additions & 2 deletions http3/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *connection) acceptStream(ctx context.Context) (quic.Stream, *datagramme
return str, datagrams, nil
}

func (c *connection) HandleUnidirectionalStreams(hijackers map[uint64]func(quic.ReceiveStream)) {
func (c *connection) HandleUnidirectionalStreams(hijackers map[uint64]func(context.Context, quic.ReceiveStream)) {
var (
rcvdControlStr atomic.Bool
rcvdQPACKEncoderStr atomic.Bool
Expand All @@ -149,7 +149,7 @@ func (c *connection) HandleUnidirectionalStreams(hijackers map[uint64]func(quic.
if err != nil {
if hijackers != nil {
if f, ok := hijackers[streamType]; ok {
f(str)
f(c.Connection.Context(), str)
return
}
}
Expand Down
8 changes: 4 additions & 4 deletions http3/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ type Server struct {
// It is invalid to specify any settings defined by RFC 9114 (HTTP/3) and RFC 9297 (HTTP Datagrams).
AdditionalSettings map[uint64]uint64

SignalValues map[uint64]func(quic.Stream)
UniStreamType map[uint64]func(quic.ReceiveStream)
SignalValues map[uint64]func(context.Context, quic.Stream)
UniStreamType map[uint64]func(context.Context, quic.ReceiveStream)

// ConnContext optionally specifies a function that modifies
// the context used for a new connection c. The provided ctx
Expand Down Expand Up @@ -455,7 +455,7 @@ func (s *Server) maxHeaderBytes() uint64 {
}

func (s *Server) handleRequest(conn *connection, str quic.Stream, datagrams *datagrammer, decoder *qpack.Decoder) {
var hijack func(quic.Stream)
var hijack func(context.Context, quic.Stream)
fp := &frameParser{
conn: conn,
r: str,
Expand All @@ -474,7 +474,7 @@ func (s *Server) handleRequest(conn *connection, str quic.Stream, datagrams *dat
return
}
if hijack != nil {
hijack(str)
hijack(conn.Connection.Context(), str)
return
}
hf, ok := frame.(*headersFrame)
Expand Down

0 comments on commit 692ecdc

Please sign in to comment.