pass the connection to the client's StreamHijacker callback

This commit is contained in:
Marten Seemann 2022-03-27 13:18:45 +01:00
parent 448e8bcf05
commit a983db0301
2 changed files with 3 additions and 3 deletions

View file

@ -43,7 +43,7 @@ type roundTripperOpts struct {
EnableDatagram bool EnableDatagram bool
MaxHeaderBytes int64 MaxHeaderBytes int64
AdditionalSettings map[uint64]uint64 AdditionalSettings map[uint64]uint64
StreamHijacker func(FrameType, quic.Stream) (hijacked bool, err error) StreamHijacker func(FrameType, quic.Connection, quic.Stream) (hijacked bool, err error)
} }
// client is a HTTP3 client doing requests // client is a HTTP3 client doing requests
@ -152,7 +152,7 @@ func (c *client) handleBidirectionalStreams() {
go func(str quic.Stream) { go func(str quic.Stream) {
for { for {
_, err := parseNextFrame(str, func(ft FrameType) (processed bool, err error) { _, err := parseNextFrame(str, func(ft FrameType) (processed bool, err error) {
return c.opts.StreamHijacker(ft, str) return c.opts.StreamHijacker(ft, c.conn, str)
}) })
if err == errHijacked { if err == errHijacked {
return return

View file

@ -56,7 +56,7 @@ type RoundTripper struct {
// Callers can either process the frame and return control of the stream back to HTTP/3 // Callers can either process the frame and return control of the stream back to HTTP/3
// (by returning hijacked false). // (by returning hijacked false).
// Alternatively, callers can take over the QUIC stream (by returning hijacked true). // Alternatively, callers can take over the QUIC stream (by returning hijacked true).
StreamHijacker func(FrameType, quic.Stream) (hijacked bool, err error) StreamHijacker func(FrameType, quic.Connection, quic.Stream) (hijacked bool, err error)
// Dial specifies an optional dial function for creating QUIC // Dial specifies an optional dial function for creating QUIC
// connections for requests. // connections for requests.