mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-07 01:08:08 +08:00
gateway: reordered headers to avoid error
cc @mappum
This commit is contained in:
parent
21575ba535
commit
c36e8dd04c
@ -135,11 +135,20 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Etag", etag)
|
||||
w.Header().Set("X-IPFS-Path", p)
|
||||
w.Header().Set("Cache-Control", "public, max-age=29030400")
|
||||
|
||||
dr, err := i.NewDagReader(nd)
|
||||
if err != nil && err != uio.ErrIsDir {
|
||||
// not a directory and still an error
|
||||
internalWebError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
// set these headers _after_ the error, for we may just not have it
|
||||
// and dont want the client to cache a 500 response...
|
||||
w.Header().Set("Etag", etag)
|
||||
w.Header().Set("Cache-Control", "public, max-age=29030400")
|
||||
|
||||
if err == nil {
|
||||
defer dr.Close()
|
||||
_, name := path.Split(urlPath)
|
||||
@ -149,12 +158,6 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err != uio.ErrIsDir {
|
||||
// not a directory and still an error
|
||||
internalWebError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
// storage for directory listing
|
||||
var dirListing []directoryItem
|
||||
// loop through files
|
||||
|
||||
Loading…
Reference in New Issue
Block a user