fix abused 404 status code

Signed-off-by: divinerapier <poriter.coco@gmail.com>
This commit is contained in:
divinerapier 2019-10-24 16:51:26 +08:00
parent 253dd20bc6
commit f1ee6b7a54
No known key found for this signature in database
GPG key ID: EA114C69199EE3BB

View file

@ -32,10 +32,15 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
fs.listDirectoryHandler(w, r)
return
}
glog.V(1).Infof("Not found %s: %v", path, err)
stats.FilerRequestCounter.WithLabelValues("read.notfound").Inc()
w.WriteHeader(http.StatusNotFound)
if err == filer2.ErrNotFound {
glog.V(1).Infof("Not found %s: %v", path, err)
stats.FilerRequestCounter.WithLabelValues("read.notfound").Inc()
w.WriteHeader(http.StatusNotFound)
} else {
glog.V(0).Infof("Internal %s: %v", path, err)
stats.FilerRequestCounter.WithLabelValues("read.internalerror").Inc()
w.WriteHeader(http.StatusInternalServerError)
}
return
}