Skip to content

Commit

Permalink
fix: subdomain redirect for dir CIDs
Browse files Browse the repository at this point in the history
Closes #7164

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>


This commit was moved from ipfs/kubo@8290ec1
  • Loading branch information
lidel committed Apr 15, 2020
1 parent 859c22d commit e1dd5d9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gateway/core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,16 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
BackLink: backLink,
Hash: hash,
}

// See statusResponseWriter.WriteHeader
// and https://github.com/ipfs/go-ipfs/issues/7164
// Note: this needs to occur before listingTemplate.Execute otherwise we get
// superfluous response.WriteHeader call from prometheus/client_golang
if w.Header().Get("Location") != "" {
w.WriteHeader(http.StatusMovedPermanently)
return
}

err = listingTemplate.Execute(w, tplData)
if err != nil {
internalWebError(w, err)
Expand Down

0 comments on commit e1dd5d9

Please sign in to comment.