Add more friendly error message for policy object (#7412)

This commit is contained in:
Roman Kalashnikov 2019-04-22 11:23:54 +03:00 committed by Harshavardhana
parent d96584ef58
commit 188cf1d5ce
2 changed files with 7 additions and 1 deletions

View File

@ -65,6 +65,7 @@ const (
ErrBadDigest ErrBadDigest
ErrEntityTooSmall ErrEntityTooSmall
ErrEntityTooLarge ErrEntityTooLarge
ErrPolicyTooLarge
ErrIncompleteBody ErrIncompleteBody
ErrInternalError ErrInternalError
ErrInvalidAccessKeyID ErrInvalidAccessKeyID
@ -398,6 +399,11 @@ var errorCodes = errorCodeMap{
Description: "Your proposed upload exceeds the maximum allowed object size.", Description: "Your proposed upload exceeds the maximum allowed object size.",
HTTPStatusCode: http.StatusBadRequest, HTTPStatusCode: http.StatusBadRequest,
}, },
ErrPolicyTooLarge: {
Code: "PolicyTooLarge",
Description: "Policy exceeds the maximum allowed document size.",
HTTPStatusCode: http.StatusBadRequest,
},
ErrIncompleteBody: { ErrIncompleteBody: {
Code: "IncompleteBody", Code: "IncompleteBody",
Description: "You did not provide the number of bytes specified by the Content-Length HTTP header.", Description: "You did not provide the number of bytes specified by the Content-Length HTTP header.",

View File

@ -71,7 +71,7 @@ func (api objectAPIHandlers) PutBucketPolicyHandler(w http.ResponseWriter, r *ht
// Error out if Content-Length is beyond allowed size. // Error out if Content-Length is beyond allowed size.
if r.ContentLength > maxBucketPolicySize { if r.ContentLength > maxBucketPolicySize {
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrEntityTooLarge), r.URL, guessIsBrowserReq(r)) writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrPolicyTooLarge), r.URL, guessIsBrowserReq(r))
return return
} }