Repository: quic-go/quic-go
Pull request #4658 (2024-09-03 07:40:59)

interop: fix server setup for the HTTP/0.9 server
This broke in #4651.

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/quic-go/quic-go/pull/4658?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 84.86%. Comparing base [(`26a3525`)](https://app.codecov.io/gh/quic-go/quic-go/commit/26a35253375af9fade678862834288fff4a6ad79?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go) to head [(`cb72646`)](https://app.codecov.io/gh/quic-go/quic-go/commit/cb726462aaf4215d43b9e82860ace7e1612d8b26?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #4658      +/-   ##
==========================================
- Coverage   84.91%   84.86%   -0.05%     
==========================================
  Files         150      147       -3     
  Lines       14869    14591     -278     
==========================================
- Hits        12625    12382     -243     
+ Misses       1719     1702      -17     
+ Partials      525      507      -18     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/quic-go/quic-go/pull/4658?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=quic-go).


Patch:
diff --git a/interop/http09/server.go b/interop/http09/server.go
index 9a6c7b32..07ac9e11 100644
--- a/interop/http09/server.go
+++ b/interop/http09/server.go
@@ -2,7 +2,6 @@ package http09
 
 import (
 	"context"
-	"errors"
 	"io"
 	"log"
 	"net/http"
@@ -33,15 +32,11 @@ func (w *responseWriter) WriteHeader(int) {}
 
 // Server is a HTTP/0.9 server listening for QUIC connections.
 type Server struct {
-	*http.Server
+	Handler *http.ServeMux
 }
 
-// ListenAndServe listens and serves HTTP/0.9 over QUIC.
+// ServeListener serves HTTP/0.9 on all connections accepted from a QUIC listener.
 func (s *Server) ServeListener(ln *quic.EarlyListener) error {
-	if s.Server == nil {
-		return errors.New("use of http3.Server without http.Server")
-	}
-
 	for {
 		conn, err := ln.Accept(context.Background())
 		if err != nil {
diff --git a/interop/server/main.go b/interop/server/main.go
index 018d9cf8..a809186d 100644
--- a/interop/server/main.go
+++ b/interop/server/main.go
@@ -15,8 +15,6 @@ import (
 	"github.com/quic-go/quic-go/interop/utils"
 )
 
-var tlsConf *tls.Config
-
 func main() {
 	logFile, err := os.Create("/logs/log.txt")
 	if err != nil {
@@ -46,20 +44,22 @@ func main() {
 		fmt.Println(err)
 		os.Exit(1)
 	}
-	tlsConf = &tls.Config{
+	tlsConf := &tls.Config{
 		Certificates: []tls.Certificate{cert},
 		KeyLogWriter: keyLog,
+		NextProtos:   []string{http09.NextProto},
 	}
 
 	switch testcase {
 	case "versionnegotiation", "handshake", "retry", "transfer", "resumption", "multiconnect", "zerortt":
-		err = runHTTP09Server(quicConf, testcase == "retry")
+		err = runHTTP09Server(tlsConf, quicConf, testcase == "retry")
 	case "chacha20":
 		reset := qtls.SetCipherSuite(tls.TLS_CHACHA20_POLY1305_SHA256)
 		defer reset()
-		err = runHTTP09Server(quicConf, false)
+		err = runHTTP09Server(tlsConf, quicConf, false)
 	case "http3":
-		err = runHTTP3Server(quicConf)
+		tlsConf.NextProtos = []string{http3.NextProtoH3}
+		err = runHTTP3Server(tlsConf, quicConf)
 	default:
 		fmt.Printf("unsupported test case: %s\n", testcase)
 		os.Exit(127)
@@ -71,7 +71,7 @@ func main() {
 	}
 }
 
-func runHTTP09Server(quicConf *quic.Config, forceRetry bool) error {
+func runHTTP09Server(tlsConf *tls.Config, quicConf *quic.Config, forceRetry bool) error {
 	http.DefaultServeMux.Handle("/", http.FileServer(http.Dir("/www")))
 	server := http09.Server{}
 
@@ -94,7 +94,7 @@ func runHTTP09Server(quicConf *quic.Config, forceRetry bool) error {
 	return server.ServeListener(ln)
 }
 
-func runHTTP3Server(quicConf *quic.Config) error {
+func runHTTP3Server(tlsConf *tls.Config, quicConf *quic.Config) error {
 	server := http3.Server{
 		Addr:       ":443",
 		TLSConfig:  tlsConf,


Test patch:
diff --git a/interop/http09/http_test.go b/interop/http09/http_test.go
index fb0e5e06..c9ef4225 100644
--- a/interop/http09/http_test.go
+++ b/interop/http09/http_test.go
@@ -27,9 +27,7 @@ var _ = Describe("HTTP 0.9 integration tests", func() {
 	})
 
 	BeforeEach(func() {
-		server := &Server{
-			Server: &http.Server{},
-		}
+		server := &Server{}
 		conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
 		Expect(err).ToNot(HaveOccurred())
 		tr := &quic.Transport{Conn: conn}