Skip to content

Commit

Permalink
Merge pull request ipfs/kubo#7165 from ipfs/fix/subdomain-dir-redirect
Browse files Browse the repository at this point in the history
fix: subdomain redirect for dir CIDs

This commit was moved from ipfs/kubo@6f4608b
  • Loading branch information
Stebalien committed Apr 15, 2020
2 parents 859c22d + e1dd5d9 commit b11009b
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 b11009b

Please sign in to comment.