From dd521c0573acb10da8840d993dc873c10df02c73 Mon Sep 17 00:00:00 2001 From: mojatter Date: Sun, 21 Aug 2022 00:56:28 +0900 Subject: [PATCH] http3: fix listening on both QUIC and TCP (#3465) --- http3/server.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/http3/server.go b/http3/server.go index 499bdc76..086bc8e2 100644 --- a/http3/server.go +++ b/http3/server.go @@ -709,19 +709,20 @@ func ListenAndServe(addr, certFile, keyFile string, handler http.Handler) error tlsConn := tls.NewListener(tcpConn, config) defer tlsConn.Close() - // Start the servers - httpServer := &http.Server{} - quicServer := &Server{ - TLSConfig: config, - } - if handler == nil { handler = http.DefaultServeMux } - httpServer.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - quicServer.SetQuicHeaders(w.Header()) - handler.ServeHTTP(w, r) - }) + // Start the servers + quicServer := &Server{ + TLSConfig: config, + Handler: handler, + } + httpServer := &http.Server{ + Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + quicServer.SetQuicHeaders(w.Header()) + handler.ServeHTTP(w, r) + }), + } hErr := make(chan error) qErr := make(chan error)