HEAD request should have Content-Length for only successful response, there is no response body for errors, just header is sufficient - fixes #603

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

"""  in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET. """
This commit is contained in:
Harshavardhana
2015-05-15 21:27:00 -07:00
parent b0925965a7
commit 7ce47130fd
2 changed files with 91 additions and 41 deletions
+26 -6
View File
@@ -285,11 +285,31 @@ func (server *minioAPI) putBucketACLHandler(w http.ResponseWriter, req *http.Req
// return responses such as 404 Not Found and 403 Forbidden.
func (server *minioAPI) headBucketHandler(w http.ResponseWriter, req *http.Request) {
acceptsContentType := getContentType(req)
// verify if bucket allows this operation
if !server.isValidOp(w, req, acceptsContentType) {
return
}
// Always a success if isValidOp succeeds
writeSuccessResponse(w, acceptsContentType)
vars := mux.Vars(req)
bucket := vars["bucket"]
_, err := server.driver.GetBucketMetadata(bucket)
switch iodine.ToError(err).(type) {
case nil:
{
writeSuccessResponse(w, acceptsContentType)
}
case drivers.BucketNotFound:
{
error := getErrorCode(NoSuchBucket)
w.WriteHeader(error.HTTPStatusCode)
}
case drivers.BucketNameInvalid:
{
error := getErrorCode(InvalidBucketName)
w.WriteHeader(error.HTTPStatusCode)
}
default:
{
log.Println(err)
error := getErrorCode(InternalError)
w.WriteHeader(error.HTTPStatusCode)
}
}
}