From: zhang Shaowen Date: Thu, 25 Jul 2019 02:09:27 +0000 (+0800) Subject: rgw: continuationToken or startAfter shouldn't be returned if not specified. X-Git-Tag: v14.2.5~128^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=47c59ace6af60979c52514689d1f21ea3d180d8b;p=ceph.git rgw: continuationToken or startAfter shouldn't be returned if not specified. Signed-off-by: zhang Shaowen (cherry picked from commit f09c55fd7ab549d2bf2f148fd9f8caa8fdc1dbe3) Conflicts: src/rgw/rgw_rest_s3.cc ws conflict --- diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index b41333e31dc5..463a2b90838b 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -739,7 +739,6 @@ protected: rgw_obj_key next_marker; rgw_obj_key end_marker; string max_keys; - string startAfter; string delimiter; string encoding_type; bool list_versions; diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 9f41cc8cec00..2edb5cc4bc20 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -715,10 +715,12 @@ if (ret < 0) { return ret; } s->info.args.get_bool("fetch-owner", &fetchOwner, false); -startAfter = s->info.args.get("start-after"); -marker = s->info.args.get("ContinuationToken"); -if(marker.empty()) { +startAfter = s->info.args.get("start-after", &start_after_exist); +continuation_token = s->info.args.get("continuation-token", &continuation_token_exist); +if(!continuation_token_exist) { marker = startAfter; +} else { + marker = continuation_token; } return 0; } @@ -1006,7 +1008,9 @@ void RGWListBucket_ObjStore_S3v2::send_versioned_response() s->formatter->open_array_section("CommonPrefixes"); s->formatter->dump_string("Prefix", pref_iter->first); s->formatter->dump_int("KeyCount",objs.size()); - s->formatter->dump_string("StartAfter", startAfter); + if (start_after_exist) { + s->formatter->dump_string("StartAfter", startAfter); + } s->formatter->close_section(); } } @@ -1044,18 +1048,18 @@ void RGWListBucket_ObjStore_S3v2::send_response() s->formatter->dump_string("EncodingType", "url"); encode_key = true; } - if (op_ret >= 0) { - vector::iterator iter; - for (iter = objs.begin(); iter != objs.end(); ++iter) { - rgw_obj_key key(iter->key); - s->formatter->open_array_section("Contents"); - if (encode_key) { - string key_name; - url_encode(key.name, key_name); - s->formatter->dump_string("Key", key_name); - } - else { - s->formatter->dump_string("Key", key.name); + if (op_ret >= 0) { + vector::iterator iter; + for (iter = objs.begin(); iter != objs.end(); ++iter) { + rgw_obj_key key(iter->key); + s->formatter->open_array_section("Contents"); + if (encode_key) { + string key_name; + url_encode(key.name, key_name); + s->formatter->dump_string("Key", key_name); + } + else { + s->formatter->dump_string("Key", key.name); } dump_time(s, "LastModified", &iter->meta.mtime); s->formatter->dump_format("ETag", "\"%s\"", iter->meta.etag.c_str()); @@ -1076,13 +1080,16 @@ void RGWListBucket_ObjStore_S3v2::send_response() s->formatter->close_section(); } } - s->formatter->dump_string("ContinuationToken", marker.name); - ldpp_dout(this, 0) << "ContinuationToken: " <formatter->dump_string("ContinuationToken", continuation_token); + } if (is_truncated && !next_marker.empty()) { s->formatter->dump_string("NextContinuationToken", next_marker.name); } s->formatter->dump_int("KeyCount",objs.size()); - s->formatter->dump_string("StartAfter", startAfter); + if (start_after_exist) { + s->formatter->dump_string("StartAfter", startAfter); + } s->formatter->close_section(); rgw_flush_formatter_and_reset(s, s->formatter); } diff --git a/src/rgw/rgw_rest_s3.h b/src/rgw/rgw_rest_s3.h index 72c8ac1fef5c..972e49107aaf 100644 --- a/src/rgw/rgw_rest_s3.h +++ b/src/rgw/rgw_rest_s3.h @@ -124,6 +124,10 @@ class RGWListBucket_ObjStore_S3 : public RGWListBucket_ObjStore { class RGWListBucket_ObjStore_S3v2 : public RGWListBucket_ObjStore_S3 { bool fetchOwner; + bool start_after_exist; + bool continuation_token_exist; + string startAfter; + string continuation_token; public: RGWListBucket_ObjStore_S3v2() : fetchOwner(false) { }