Merge pull request #913 from harshavardhana/http-status

Reply back proper statuses for DeleteBucket/DeleteObject
master
Harshavardhana 9 years ago
commit 5fb46cf75c
  1. 6
      api-response.go
  2. 2
      bucket-handlers.go
  3. 4
      object-handlers.go
  4. 4
      server_fs_test.go

@ -212,6 +212,12 @@ func writeSuccessResponse(w http.ResponseWriter) {
w.WriteHeader(http.StatusOK)
}
// writeSuccessNoContent write success headers with http status 204
func writeSuccessNoContent(w http.ResponseWriter) {
setCommonHeaders(w, 0)
w.WriteHeader(http.StatusNoContent)
}
// writeErrorRespone write error headers
func writeErrorResponse(w http.ResponseWriter, req *http.Request, errorType int, resource string) {
error := getErrorCode(errorType)

@ -452,5 +452,5 @@ func (api API) DeleteBucketHandler(w http.ResponseWriter, req *http.Request) {
}
return
}
writeSuccessResponse(w)
writeSuccessNoContent(w)
}

@ -376,8 +376,7 @@ func (api API) AbortMultipartUploadHandler(w http.ResponseWriter, req *http.Requ
}
return
}
setCommonHeaders(w, 0)
w.WriteHeader(http.StatusNoContent)
writeSuccessNoContent(w)
}
// ListObjectPartsHandler - List object parts
@ -531,4 +530,5 @@ func (api API) DeleteObjectHandler(w http.ResponseWriter, req *http.Request) {
writeErrorResponse(w, req, InternalError, req.URL.Path)
}
}
writeSuccessNoContent(w)
}

@ -275,7 +275,7 @@ func (s *MyAPIFSCacheSuite) TestDeleteBucket(c *C) {
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
}
func (s *MyAPIFSCacheSuite) TestDeleteObject(c *C) {
@ -300,7 +300,7 @@ func (s *MyAPIFSCacheSuite) TestDeleteObject(c *C) {
client = http.Client{}
response, err = client.Do(request)
c.Assert(err, IsNil)
c.Assert(response.StatusCode, Equals, http.StatusOK)
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
}
func (s *MyAPIFSCacheSuite) TestNonExistantBucket(c *C) {

Loading…
Cancel
Save