Fix create badhttp2 server

This commit is contained in:
世界 2023-03-01 10:41:09 +08:00
parent 5af8d001ae
commit b14ae51f71
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 14 additions and 22 deletions

View file

@ -98,18 +98,14 @@ func (s *Server) fallbackRequest(ctx context.Context, writer http.ResponseWriter
}
func (s *Server) Serve(listener net.Listener) error {
fixTLSConfig := s.httpServer.TLSConfig == nil
if s.httpServer.TLSConfig != nil {
err := http2.ConfigureServer(s.httpServer, s.h2Server)
if err != nil {
return err
}
if fixTLSConfig {
s.httpServer.TLSConfig = nil
}
if s.httpServer.TLSConfig == nil {
return s.httpServer.Serve(listener)
} else {
return s.httpServer.ServeTLS(listener, "", "")
} else {
return s.httpServer.Serve(listener)
}
}

View file

@ -134,18 +134,14 @@ func (s *Server) fallbackRequest(ctx context.Context, writer http.ResponseWriter
}
func (s *Server) Serve(listener net.Listener) error {
fixTLSConfig := s.httpServer.TLSConfig == nil
if s.httpServer.TLSConfig != nil {
err := http2.ConfigureServer(s.httpServer, s.h2Server)
if err != nil {
return err
}
if fixTLSConfig {
s.httpServer.TLSConfig = nil
}
if s.httpServer.TLSConfig == nil {
return s.httpServer.Serve(listener)
} else {
return s.httpServer.ServeTLS(listener, "", "")
} else {
return s.httpServer.Serve(listener)
}
}