forked from quic-go/quic-go
interop: fix server setup for the HTTP/0.9 server (#4658)
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user