@cryptotaxi247 / kubo / commits / d4952f2a7

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.

Peter Wu committed May 18, 2020 at 13:58 UTC d4952f2a73b2dd33d8c35ab1bae3bc381fdb5088
1 file changed +3
core/corehttp/gateway_handler.go
+3
@@ -300,6 +300,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
300 return
301 }
302
303 + // A HTML directory index will be presented, be sure to set the correct
304 + // type instead of relying on autodetection (which may fail).
305 + w.Header().Set("Content-Type", "text/html")
306 if r.Method == http.MethodHead {
307 return
308 }