From f68e15da892afbea0870f4831227c3cb80d58f68 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 6 Feb 2014 12:00:58 -0800 Subject: [PATCH] set to 404 when failed to read file id --- go/weed/weed_server/volume_server_handlers.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go/weed/weed_server/volume_server_handlers.go b/go/weed/weed_server/volume_server_handlers.go index e47ac96d3..572110f07 100644 --- a/go/weed/weed_server/volume_server_handlers.go +++ b/go/weed/weed_server/volume_server_handlers.go @@ -90,11 +90,13 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, volumeId, err := storage.NewVolumeId(vid) if err != nil { glog.V(2).Infoln("parsing error:", err, r.URL.Path) + w.WriteHeader(http.StatusNotFound) return } err = n.ParsePath(fid) if err != nil { glog.V(2).Infoln("parsing fid error:", err, r.URL.Path) + w.WriteHeader(http.StatusNotFound) return } @@ -102,7 +104,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, if !vs.store.HasVolume(volumeId) { lookupResult, err := operation.Lookup(vs.masterNode, volumeId) glog.V(2).Infoln("volume", volumeId, "found on", lookupResult, "error", err) - if err == nil && len(lookupResult.Locations)>0{ + if err == nil && len(lookupResult.Locations) > 0 { http.Redirect(w, r, "http://"+lookupResult.Locations[0].PublicUrl+r.URL.Path, http.StatusMovedPermanently) } else { glog.V(2).Infoln("lookup error:", err, r.URL.Path)