remove h2c support
Alan Pearce alan@alanpearce.eu
Fri, 28 Jun 2024 20:55:03 +0200
2 files changed, 2 insertions(+), 28 deletions(-)
M go.mod → go.mod
@@ -29,7 +29,6 @@ github.com/sykesm/zap-logfmt v0.0.4 github.com/thessem/zap-prettyconsole v0.5.0 github.com/yuin/goldmark v1.7.4 go.uber.org/zap v1.27.0 - golang.org/x/net v0.26.0 ) require ( @@ -94,6 +93,7 @@ golang.org/x/crypto v0.24.0 // indirect golang.org/x/crypto/x509roots/fallback v0.0.0-20240624163532-1c7450041f58 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/mod v0.18.0 // indirect + golang.org/x/net v0.26.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/term v0.21.0 // indirect
M internal/server/server.go → internal/server/server.go
@@ -21,8 +21,6 @@ "github.com/ardanlabs/conf/v3" "github.com/osdevisnot/sorvor/pkg/livereload" "github.com/pkg/errors" - "golang.org/x/net/http2" - "golang.org/x/net/http2/h2c" ) var ( @@ -83,25 +81,6 @@ } func serverHeaderHandler(wrappedHandler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - log.Debug( - "headers", - "proto", - r.Header.Get("X-Forwarded-Proto"), - "host", - r.Header.Get("X-Forwarded-Host"), - "scheme", - r.URL.Scheme, - "secure", - r.TLS != nil, - ) - log.Debug("host", "request", r.Host, "header", r.Header.Get("Host")) - if r.ProtoMajor >= 2 && r.Header.Get("Host") != "" { - // net/http does this for HTTP/1.1, but not h2c - // TODO: check with HTTP/2.0 (i.e. with TLS) - log.Debug("host", "request", r.Host, "header", r.Header.Get("Host")) - r.Host = r.Header.Get("Host") - r.Header.Del("Host") - } w.Header().Set("Server", serverHeader) wrappedHandler.ServeHTTP(w, r) }) @@ -223,12 +202,7 @@ ReadTimeout: 1 * time.Minute, WriteTimeout: 2 * time.Minute, IdleTimeout: 10 * time.Minute, Addr: listenAddress, - Handler: http.MaxBytesHandler(h2c.NewHandler( - top, - &http2.Server{ - IdleTimeout: 15 * time.Minute, - }, - ), 0), + Handler: top, }, redirectHandler: redirectHandler, config: config,