gateway: reordered headers to avoid error

cc @mappum
This commit is contained in:
Juan Batiz-Benet 2015-01-28 13:10:34 -08:00
parent 21575ba535
commit c36e8dd04c

View File

@ -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