From d4952f2a73b2dd33d8c35ab1bae3bc381fdb5088 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 18 May 2020 13:58:09 +0200 Subject: [PATCH] fix(gateway): ensure directory listings have Content-Type text/html Files already have an explicit Content-Type set. Be sure to do this for directory listings as well to avoid a fallback to autodetection in net/http. That fallback fails when a ResponseWriter is installed that performs compression. --- core/corehttp/gateway_handler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/corehttp/gateway_handler.go b/core/corehttp/gateway_handler.go index e24a999d5..78afb2bf7 100644 --- a/core/corehttp/gateway_handler.go +++ b/core/corehttp/gateway_handler.go @@ -300,6 +300,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + // A HTML directory index will be presented, be sure to set the correct + // type instead of relying on autodetection (which may fail). + w.Header().Set("Content-Type", "text/html") if r.Method == http.MethodHead { return }