Repository: quic-go/quic-go
Pull request #4695 (2024-10-14 05:28:39)

http3: don't expose ClientConn.HandleUnidirectionalStreams


Patch:
diff --git a/http3/capsule.go b/http3/capsule.go
index 09114a58..132e6c32 100644
--- a/http3/capsule.go
+++ b/http3/capsule.go
@@ -6,9 +6,12 @@ import (
 	"github.com/quic-go/quic-go/quicvarint"
 )
 
-// CapsuleType is the type of the capsule.
+// CapsuleType is the type of the capsule
 type CapsuleType uint64
 
+// CapsuleProtocolHeader is the header value used to advertise support for the capsule protocol
+const CapsuleProtocolHeader = "Capsule-Protocol"
+
 type exactReader struct {
 	R io.LimitedReader
 }
diff --git a/http3/client.go b/http3/client.go
index ff8ec2fd..feb14cbc 100644
--- a/http3/client.go
+++ b/http3/client.go
@@ -111,7 +111,7 @@ func newClientConn(
 	if streamHijacker != nil {
 		go c.handleBidirectionalStreams(streamHijacker)
 	}
-	go c.connection.HandleUnidirectionalStreams(uniStreamHijacker)
+	go c.connection.handleUnidirectionalStreams(uniStreamHijacker)
 	return c
 }
 
diff --git a/http3/conn.go b/http3/conn.go
index 0f372b0d..2b5b9a82 100644
--- a/http3/conn.go
+++ b/http3/conn.go
@@ -170,7 +170,7 @@ func (c *connection) CloseWithError(code quic.ApplicationErrorCode, msg string)
 	return c.Connection.CloseWithError(code, msg)
 }
 
-func (c *connection) HandleUnidirectionalStreams(hijack func(StreamType, quic.ConnectionTracingID, quic.ReceiveStream, error) (hijacked bool)) {
+func (c *connection) handleUnidirectionalStreams(hijack func(StreamType, quic.ConnectionTracingID, quic.ReceiveStream, error) (hijacked bool)) {
 	var (
 		rcvdControlStr      atomic.Bool
 		rcvdQPACKEncoderStr atomic.Bool
diff --git a/http3/server.go b/http3/server.go
index 6f8f5e47..076aa10f 100644
--- a/http3/server.go
+++ b/http3/server.go
@@ -526,7 +526,7 @@ func (s *Server) handleConn(conn quic.Connection) error {
 		s.Logger,
 		s.IdleTimeout,
 	)
-	go hconn.HandleUnidirectionalStreams(s.UniStreamHijacker)
+	go hconn.handleUnidirectionalStreams(s.UniStreamHijacker)
 
 	var nextStreamID quic.StreamID
 	var wg sync.WaitGroup


Test patch:
diff --git a/http3/conn_test.go b/http3/conn_test.go
index 1b1ff257..552a6f4f 100644
--- a/http3/conn_test.go
+++ b/http3/conn_test.go
@@ -46,7 +46,7 @@ var _ = Describe("Connection", func() {
 			go func() {
 				defer GinkgoRecover()
 				defer close(done)
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(conn.ReceivedSettings()).Should(BeClosed())
 			Expect(conn.Settings().EnableDatagrams).To(BeTrue())
@@ -85,7 +85,7 @@ var _ = Describe("Connection", func() {
 			go func() {
 				defer GinkgoRecover()
 				defer close(done)
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(closed).Should(BeClosed())
 			Eventually(done).Should(BeClosed())
@@ -123,7 +123,7 @@ var _ = Describe("Connection", func() {
 				go func() {
 					defer GinkgoRecover()
 					defer close(done)
-					conn.HandleUnidirectionalStreams(nil)
+					conn.handleUnidirectionalStreams(nil)
 				}()
 				Eventually(done).Should(BeClosed())
 			})
@@ -159,7 +159,7 @@ var _ = Describe("Connection", func() {
 				go func() {
 					defer GinkgoRecover()
 					defer close(done)
-					conn.HandleUnidirectionalStreams(nil)
+					conn.handleUnidirectionalStreams(nil)
 				}()
 				Eventually(done).Should(BeClosed())
 			})
@@ -186,7 +186,7 @@ var _ = Describe("Connection", func() {
 			go func() {
 				defer GinkgoRecover()
 				defer close(done)
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(done).Should(BeClosed())
 			Eventually(reset).Should(BeClosed())
@@ -218,7 +218,7 @@ var _ = Describe("Connection", func() {
 			go func() {
 				defer GinkgoRecover()
 				defer close(done)
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(done).Should(BeClosed())
 			Eventually(closed).Should(BeClosed())
@@ -250,7 +250,7 @@ var _ = Describe("Connection", func() {
 			go func() {
 				defer GinkgoRecover()
 				defer close(done)
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(done).Should(BeClosed())
 			Eventually(closed).Should(BeClosed())
@@ -287,7 +287,7 @@ var _ = Describe("Connection", func() {
 				go func() {
 					defer GinkgoRecover()
 					defer close(done)
-					conn.HandleUnidirectionalStreams(nil)
+					conn.handleUnidirectionalStreams(nil)
 				}()
 				Eventually(done).Should(BeClosed())
 				Eventually(closed).Should(BeClosed())
@@ -321,7 +321,7 @@ var _ = Describe("Connection", func() {
 			go func() {
 				defer GinkgoRecover()
 				defer close(done)
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(done).Should(BeClosed())
 			Eventually(closed).Should(BeClosed())
@@ -363,7 +363,7 @@ var _ = Describe("Connection", func() {
 			})
 			go func() {
 				defer GinkgoRecover()
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(done).Should(BeClosed())
 		})
@@ -378,7 +378,7 @@ var _ = Describe("Connection", func() {
 			})
 			go func() {
 				defer GinkgoRecover()
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(done).Should(BeClosed())
 		})
@@ -395,7 +395,7 @@ var _ = Describe("Connection", func() {
 			})
 			go func() {
 				defer GinkgoRecover()
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 			Eventually(delivered).Should(BeClosed())
 
@@ -430,7 +430,7 @@ var _ = Describe("Connection", func() {
 			qconn.EXPECT().ReceiveDatagram(gomock.Any()).Return(nil, errors.New("test done"))
 			go func() {
 				defer GinkgoRecover()
-				conn.HandleUnidirectionalStreams(nil)
+				conn.handleUnidirectionalStreams(nil)
 			}()
 
 			data, err := str.ReceiveDatagram(context.Background())