mirror of
https://github.com/minio/minio.git
synced 2025-01-12 07:23:23 -05:00
Merge pull request #913 from harshavardhana/http-status
Reply back proper statuses for DeleteBucket/DeleteObject
This commit is contained in:
commit
5fb46cf75c
@ -46,7 +46,7 @@ func generateRequestID() []byte {
|
|||||||
func setCommonHeaders(w http.ResponseWriter, contentLength int) {
|
func setCommonHeaders(w http.ResponseWriter, contentLength int) {
|
||||||
// set unique request ID for each reply
|
// set unique request ID for each reply
|
||||||
w.Header().Set("X-Amz-Request-Id", string(generateRequestID()))
|
w.Header().Set("X-Amz-Request-Id", string(generateRequestID()))
|
||||||
w.Header().Set("Server", ("Minio/" + minioReleaseTag + " (" + runtime.GOOS + ";" + runtime.GOARCH + ")"))
|
w.Header().Set("Server", ("Minio/" + minioReleaseTag + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")"))
|
||||||
w.Header().Set("Accept-Ranges", "bytes")
|
w.Header().Set("Accept-Ranges", "bytes")
|
||||||
w.Header().Set("Connection", "close")
|
w.Header().Set("Connection", "close")
|
||||||
// should be set to '0' by default
|
// should be set to '0' by default
|
||||||
|
@ -212,6 +212,12 @@ func writeSuccessResponse(w http.ResponseWriter) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
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
|
// writeErrorRespone write error headers
|
||||||
func writeErrorResponse(w http.ResponseWriter, req *http.Request, errorType int, resource string) {
|
func writeErrorResponse(w http.ResponseWriter, req *http.Request, errorType int, resource string) {
|
||||||
error := getErrorCode(errorType)
|
error := getErrorCode(errorType)
|
||||||
|
@ -452,5 +452,5 @@ func (api API) DeleteBucketHandler(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
writeSuccessResponse(w)
|
writeSuccessNoContent(w)
|
||||||
}
|
}
|
||||||
|
@ -376,8 +376,7 @@ func (api API) AbortMultipartUploadHandler(w http.ResponseWriter, req *http.Requ
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setCommonHeaders(w, 0)
|
writeSuccessNoContent(w)
|
||||||
w.WriteHeader(http.StatusNoContent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListObjectPartsHandler - List object parts
|
// 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)
|
writeErrorResponse(w, req, InternalError, req.URL.Path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
writeSuccessNoContent(w)
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ func (s *MyAPIFSCacheSuite) TestDeleteBucket(c *C) {
|
|||||||
client = http.Client{}
|
client = http.Client{}
|
||||||
response, err = client.Do(request)
|
response, err = client.Do(request)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPIFSCacheSuite) TestDeleteObject(c *C) {
|
func (s *MyAPIFSCacheSuite) TestDeleteObject(c *C) {
|
||||||
@ -300,7 +300,7 @@ func (s *MyAPIFSCacheSuite) TestDeleteObject(c *C) {
|
|||||||
client = http.Client{}
|
client = http.Client{}
|
||||||
response, err = client.Do(request)
|
response, err = client.Do(request)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MyAPIFSCacheSuite) TestNonExistantBucket(c *C) {
|
func (s *MyAPIFSCacheSuite) TestNonExistantBucket(c *C) {
|
||||||
|
Loading…
Reference in New Issue
Block a user