提交 c36e8dd0 作者: Juan Batiz-Benet

gateway: reordered headers to avoid error

cc @mappum
上级 21575ba5
......@@ -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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论