Add Etag support

This commit is contained in:
Chris Lu
2014-07-22 00:24:50 -07:00
parent 5d88cec2df
commit 530927db64
2 changed files with 14 additions and 0 deletions

View File

@@ -90,6 +90,12 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
}
}
}
etag := n.Etag()
if inm := r.Header.Get("If-None-Match"); inm == etag {
w.WriteHeader(http.StatusNotModified)
return
}
w.Header().Set("Etag", etag)
if n.NameSize > 0 && filename == "" {
filename = string(n.Name)
dotIndex := strings.LastIndex(filename, ".")