Skip to content

Commit

Permalink
fix(gateway): ensure directory listings have Content-Type text/html
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Lekensteyn committed May 20, 2020
1 parent 7c7888c commit d4952f2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d4952f2

Please sign in to comment.