about summary refs log tree commit diff stats
path: root/internal/server/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/server/server.go')
-rw-r--r--internal/server/server.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index b35b6dd..61d5790 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -52,6 +52,12 @@ func applyDevModeOverrides(config *cfg.Config, listenAddress string) {
 
 func serverHeaderHandler(wrappedHandler http.Handler) http.Handler {
 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+		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)
+			r.Host = r.Header.Get("Host")
+			r.Header.Del("Host")
+		}
 		w.Header().Set("Server", serverHeader)
 		wrappedHandler.ServeHTTP(w, r)
 	})