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.
This commit is contained in:
Peter Wu 2020-05-18 13:58:09 +02:00
parent 7c7888c4db
commit d4952f2a73

View File

@ -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
}