From e5a256df0c331d3a8970cef948efb2e30e012b38 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Wed, 19 Jan 2022 23:20:07 +0300 Subject: [PATCH] [#316] Return badrequest err if couldnt parse body Signed-off-by: Angira Kekteeva --- api/handler/acl.go | 4 ++-- api/handler/delete.go | 2 +- api/handler/put.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/handler/acl.go b/api/handler/acl.go index 86afb8e39..9308377de 100644 --- a/api/handler/acl.go +++ b/api/handler/acl.go @@ -171,7 +171,7 @@ func (h *handler) PutBucketACLHandler(w http.ResponseWriter, r *http.Request) { return } } else if err := xml.NewDecoder(r.Body).Decode(list); err != nil { - h.logAndSendError(w, "could not parse bucket acl", reqInfo, err) + h.logAndSendError(w, "could not parse bucket acl", reqInfo, errors.GetAPIError(errors.ErrMalformedXML)) return } @@ -263,7 +263,7 @@ func (h *handler) PutObjectACLHandler(w http.ResponseWriter, r *http.Request) { return } } else if err := xml.NewDecoder(r.Body).Decode(list); err != nil { - h.logAndSendError(w, "could not parse bucket acl", reqInfo, err) + h.logAndSendError(w, "could not parse bucket acl", reqInfo, errors.GetAPIError(errors.ErrMalformedXML)) return } diff --git a/api/handler/delete.go b/api/handler/delete.go index eb27ee796..281bbd115 100644 --- a/api/handler/delete.go +++ b/api/handler/delete.go @@ -106,7 +106,7 @@ func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Re // Unmarshal list of keys to be deleted. requested := &DeleteObjectsRequest{} if err := xml.NewDecoder(r.Body).Decode(requested); err != nil { - h.logAndSendError(w, "couldn't decode body", reqInfo, err) + h.logAndSendError(w, "couldn't decode body", reqInfo, errors.GetAPIError(errors.ErrMalformedXML)) return } diff --git a/api/handler/put.go b/api/handler/put.go index d753b7191..0bd1f6097 100644 --- a/api/handler/put.go +++ b/api/handler/put.go @@ -612,7 +612,7 @@ func parseLocationConstraint(r *http.Request) (*createBucketParams, error) { params := new(createBucketParams) if err := xml.NewDecoder(r.Body).Decode(params); err != nil { - return nil, err + return nil, errors.GetAPIError(errors.ErrMalformedXML) } return params, nil }