mirror of
https://github.com/minio/minio.git
synced 2024-12-23 21:55:53 -05:00
Merge pull request #736 from harshavardhana/pr_out_head_shouldn_t_have_any_body_handle_it_in_writeerrorresponse_
HEAD shouldn't have any body, handle it in writeErrorResponse()
This commit is contained in:
commit
74e44cd0c4
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ checkgopath:
|
||||
@for mcpath in $(echo ${GOPATH} | sed 's/:/\n/g' | grep -v Godeps); do if [ ! -d ${mcpath}/src/github.com/minio/minio ]; then echo "Project not found in ${mcpath}, please follow instructions provided at https://github.com/minio/minio/blob/master/CONTRIBUTING.md#setup-your-minio-github-repository" && exit 1; fi done
|
||||
|
||||
getdeps: checkdeps checkgopath
|
||||
@go get github.com/minio/godep && echo "Installed godep:"
|
||||
@go get github.com/tools/godep && echo "Installed godep:"
|
||||
@go get github.com/golang/lint/golint && echo "Installed golint:"
|
||||
@go get golang.org/x/tools/cmd/vet && echo "Installed vet:"
|
||||
@go get github.com/fzipp/gocyclo && echo "Installed gocyclo:"
|
||||
|
@ -405,17 +405,13 @@ func (api Minio) HeadBucketHandler(w http.ResponseWriter, req *http.Request) {
|
||||
case nil:
|
||||
writeSuccessResponse(w, acceptsContentType)
|
||||
case donut.SignatureDoesNotMatch:
|
||||
error := getErrorCode(SignatureDoesNotMatch)
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
|
||||
case donut.BucketNotFound:
|
||||
error := getErrorCode(NoSuchBucket)
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, NoSuchBucket, acceptsContentType, req.URL.Path)
|
||||
case donut.BucketNameInvalid:
|
||||
error := getErrorCode(InvalidBucketName)
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, InvalidBucketName, acceptsContentType, req.URL.Path)
|
||||
default:
|
||||
log.Error.Println(iodine.New(err, nil))
|
||||
error := getErrorCode(InternalError)
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
|
||||
}
|
||||
}
|
||||
|
@ -162,12 +162,7 @@ func IgnoreResourcesHandler(h http.Handler) http.Handler {
|
||||
func (h resourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
acceptsContentType := getContentType(r)
|
||||
if ignoreNotImplementedObjectResources(r) || ignoreNotImplementedBucketResources(r) {
|
||||
error := getErrorCode(NotImplemented)
|
||||
errorResponse := getErrorResponse(error, "")
|
||||
encodeErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
||||
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodeErrorResponse))
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
w.Write(encodeErrorResponse)
|
||||
writeErrorResponse(w, r, NotImplemented, acceptsContentType, r.URL.Path)
|
||||
return
|
||||
}
|
||||
h.handler.ServeHTTP(w, r)
|
||||
|
@ -147,30 +147,18 @@ func (api Minio) HeadObjectHandler(w http.ResponseWriter, req *http.Request) {
|
||||
setObjectHeaders(w, metadata)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
case donut.SignatureDoesNotMatch:
|
||||
error := getErrorCode(SignatureDoesNotMatch)
|
||||
w.Header().Set("Server", "Minio")
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, SignatureDoesNotMatch, acceptsContentType, req.URL.Path)
|
||||
case donut.BucketNameInvalid:
|
||||
error := getErrorCode(InvalidBucketName)
|
||||
w.Header().Set("Server", "Minio")
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, InvalidBucketName, acceptsContentType, req.URL.Path)
|
||||
case donut.BucketNotFound:
|
||||
error := getErrorCode(NoSuchBucket)
|
||||
w.Header().Set("Server", "Minio")
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, NoSuchBucket, acceptsContentType, req.URL.Path)
|
||||
case donut.ObjectNotFound:
|
||||
error := getErrorCode(NoSuchKey)
|
||||
w.Header().Set("Server", "Minio")
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path)
|
||||
case donut.ObjectNameInvalid:
|
||||
error := getErrorCode(NoSuchKey)
|
||||
w.Header().Set("Server", "Minio")
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path)
|
||||
default:
|
||||
log.Error.Println(iodine.New(err, nil))
|
||||
error := getErrorCode(InternalError)
|
||||
w.Header().Set("Server", "Minio")
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,9 @@ func writeErrorResponse(w http.ResponseWriter, req *http.Request, errorType int,
|
||||
setCommonHeaders(w, getContentTypeString(acceptsContentType), len(encodedErrorResponse))
|
||||
// write Header
|
||||
w.WriteHeader(error.HTTPStatusCode)
|
||||
// write error body
|
||||
w.Write(encodedErrorResponse)
|
||||
// HEAD should have no body
|
||||
if req.Method != "HEAD" {
|
||||
// write error body
|
||||
w.Write(encodedErrorResponse)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user