diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 35bff735dbd..70d51f484d7 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -666,7 +666,7 @@ void RGWListBuckets::execute() marker, read_count, should_get_stats()); if (!started) { - send_response_begin(); + send_response_begin(buckets.count() > 0); started = true; } @@ -692,7 +692,7 @@ void RGWListBuckets::execute() send_end: if (!started) { - send_response_begin(); + send_response_begin(false); } send_response_end(); } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index f0f773b5ac8..b3e8c86e3f0 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -140,7 +140,7 @@ public: void execute(); virtual int get_params() = 0; - virtual void send_response_begin() = 0; + virtual void send_response_begin(bool has_buckets) = 0; virtual void send_response_data(RGWUserBuckets& buckets) = 0; virtual void send_response_end() = 0; virtual void send_response() {} diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 6866d17e8aa..38fab1bd2c1 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -156,7 +156,7 @@ send_data: return 0; } -void RGWListBuckets_ObjStore_S3::send_response_begin() +void RGWListBuckets_ObjStore_S3::send_response_begin(bool has_buckets) { if (ret) set_req_state_err(s, ret); diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index 16325978a7a..bf97c1a2993 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -26,7 +26,7 @@ public: ~RGWListBuckets_ObjStore_S3() {} int get_params() { return 0; } - virtual void send_response_begin(); + virtual void send_response_begin(bool has_buckets); virtual void send_response_data(RGWUserBuckets& buckets); virtual void send_response_end(); }; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 635bd2e7a01..f656bfb6821 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -43,10 +43,14 @@ int RGWListBuckets_ObjStore_SWIFT::get_params() return 0; } -void RGWListBuckets_ObjStore_SWIFT::send_response_begin() +void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets) { - if (ret) + if (ret) { set_req_state_err(s, ret); + } else if (!has_buckets && s->format == RGW_FORMAT_PLAIN) { + ret = STATUS_NO_CONTENT; + set_req_state_err(s, ret); + } dump_errno(s); end_header(s); diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index e721f1cd1c1..e4b6f0bccee 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -20,7 +20,7 @@ public: ~RGWListBuckets_ObjStore_SWIFT() {} int get_params(); - void send_response_begin(); + void send_response_begin(bool has_buckets); void send_response_data(RGWUserBuckets& buckets); void send_response_end();