Browse Source

adding HEAD support

pull/2/head
Chris Lu 12 years ago
parent
commit
4d8ce2fe26
  1. 8
      go/weed/volume.go

8
go/weed/volume.go

@ -89,14 +89,16 @@ func vacuumVolumeCommitHandler(w http.ResponseWriter, r *http.Request) {
func storeHandler(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "GET":
GetHandler(w, r)
GetOrHeadHandler(w, r, true)
case "HEAD":
GetOrHeadHandler(w, r, false)
case "DELETE":
DeleteHandler(w, r)
case "POST":
PostHandler(w, r)
}
}
func GetHandler(w http.ResponseWriter, r *http.Request) {
func GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) {
n := new(storage.Needle)
vid, fid, ext := parseURLPath(r.URL.Path)
volumeId, err := storage.NewVolumeId(vid)
@ -163,10 +165,12 @@ func GetHandler(w http.ResponseWriter, r *http.Request) {
}
}
w.Header().Set("Content-Length", strconv.Itoa(len(n.Data)))
if isGetMethod {
if _, e = w.Write(n.Data); e != nil {
debug("response write error:", e)
}
}
}
func PostHandler(w http.ResponseWriter, r *http.Request) {
if e := r.ParseForm(); e != nil {
debug("form parse error:", e)

Loading…
Cancel
Save