From befc673930c8de930faa4f27673deee49a1aa8be Mon Sep 17 00:00:00 2001 From: Matthew Oliver Date: Thu, 14 May 2020 11:31:56 +1000 Subject: [PATCH] rgw: S3 Put Bucket Policy should return 204 on success Currently RGW returns a 200 on a successful PUT on a bucket policy but the S3 api extects a 204, which makes sense as it's a success without any contect returned: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTpolicy.html The sample response in the example above is a 204. This patch checks the op_ret in `RGWPutBucketPolicy::send_response()` and on a success we turn it to a 204 (or STATUS_NO_CONTENT). Fixes: https://tracker.ceph.com/issues/45467 Signed-off-by: Matthew Oliver (cherry picked from commit 7fddff78c98ef9a3c73581b892c7dfa04b64cdb3) --- src/rgw/rgw_op.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 9ca7e1cfb821f..5a19feedb10de 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -7500,6 +7500,10 @@ void RGWDefaultResponseOp::send_response() { void RGWPutBucketPolicy::send_response() { + if (!op_ret) { + /* A successful Put Bucket Policy should return a 204 on success */ + op_ret = STATUS_NO_CONTENT; + } if (op_ret) { set_req_state_err(s, op_ret); } -- 2.39.5