From: 胡玮文 Date: Thu, 24 Sep 2020 15:34:43 +0000 (+0800) Subject: rgw: fix: S3 API KeyCount incorrect return. X-Git-Tag: v15.2.8~5^2~1^2~26^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F37849%2Fhead;p=ceph.git rgw: fix: S3 API KeyCount incorrect return. KeyCount should return object count + common prefix count. see S3 example: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#API_ListObjectsV2_Example_5 Related: https://github.com/docker/distribution/issues/3200 Signed-off-by: 胡玮文 (cherry picked from commit f96a6fdad16da2a7093f538ee577248dfbc65ca1) --- diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index d8738a4f5b47..d3ac614fc7f0 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -1855,7 +1855,7 @@ void RGWListBucket_ObjStore_S3v2::send_response() if (is_truncated && !next_marker.empty()) { s->formatter->dump_string("NextContinuationToken", next_marker.name); } - s->formatter->dump_int("KeyCount",objs.size()); + s->formatter->dump_int("KeyCount", objs.size() + common_prefixes.size()); if (start_after_exist) { s->formatter->dump_string("StartAfter", startAfter); }