From 0fb7d2fdcb5ad199915dbe16d7e06d3f04c67eae Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 28 Jun 2024 20:55:03 +0200 Subject: remove h2c support --- internal/server/server.go | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'internal/server') diff --git a/internal/server/server.go b/internal/server/server.go index f922f6d..9dcf09f 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -21,8 +21,6 @@ import ( "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 updateCSPHashes(config *cfg.Config, r *builder.Result) { 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 @@ func New(runtimeConfig *Config) (*Server, error) { 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, -- cgit 1.4.1