mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
adding HEAD support
This commit is contained in:
parent
437532d559
commit
4d8ce2fe26
|
@ -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,8 +165,10 @@ func GetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(n.Data)))
|
||||
if _, e = w.Write(n.Data); e != nil {
|
||||
debug("response write error:", e)
|
||||
if isGetMethod {
|
||||
if _, e = w.Write(n.Data); e != nil {
|
||||
debug("response write error:", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
func PostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
Loading…
Reference in a new issue