mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-27 20:59:42 +08:00
add error handling when non-multipart request comes in
git-svn-id: https://weed-fs.googlecode.com/svn/trunk@49 282b0af5-e82d-9cf1-ede4-77906d7719d0
This commit is contained in:
parent
de6e1442d7
commit
74989d69c9
@ -72,10 +72,15 @@ func PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
if e != nil {
|
if e != nil {
|
||||||
writeJson(w, r, e)
|
writeJson(w, r, e)
|
||||||
} else {
|
} else {
|
||||||
ret := store.Write(volumeId, storage.NewNeedle(r))
|
needle, ne := storage.NewNeedle(r)
|
||||||
m := make(map[string]uint32)
|
if ne!=nil{
|
||||||
m["size"] = ret
|
writeJson(w, r, ne)
|
||||||
writeJson(w, r, m)
|
}else{
|
||||||
|
ret := store.Write(volumeId, needle)
|
||||||
|
m := make(map[string]uint32)
|
||||||
|
m["size"] = ret
|
||||||
|
writeJson(w, r, m)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func DeleteHandler(w http.ResponseWriter, r *http.Request) {
|
func DeleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -20,12 +20,14 @@ type Needle struct {
|
|||||||
Padding []byte "Aligned to 8 bytes"
|
Padding []byte "Aligned to 8 bytes"
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNeedle(r *http.Request) (n *Needle) {
|
func NewNeedle(r *http.Request) (n *Needle, e error) {
|
||||||
|
|
||||||
n = new(Needle)
|
n = new(Needle)
|
||||||
form, fe := r.MultipartReader()
|
form, fe := r.MultipartReader()
|
||||||
if fe != nil {
|
if fe != nil {
|
||||||
log.Fatalf("MultipartReader [ERROR] %s\n", fe)
|
log.Printf("MultipartReader [ERROR] %s\n", fe)
|
||||||
|
e = fe
|
||||||
|
return
|
||||||
}
|
}
|
||||||
part, _ := form.NextPart()
|
part, _ := form.NextPart()
|
||||||
data, _ := ioutil.ReadAll(part)
|
data, _ := ioutil.ReadAll(part)
|
||||||
|
Loading…
Reference in New Issue
Block a user