From 6c534ba3a0ab2b224c17e5856ae0686b3f916fd2 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Fri, 18 Oct 2024 15:50:14 -0400 Subject: [PATCH] rgw:attrs: dump marker and max_parts only if sent Suggested by Casey. Signed-off-by: Matt Benjamin --- src/rgw/rgw_op.h | 4 ++-- src/rgw/rgw_rest_s3.cc | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index d3980bc718315..7ab956b7b9e51 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -1650,8 +1650,8 @@ class RGWGetObjAttrs : public RGWGetObj { protected: std::string version_id; std::string expected_bucket_owner; - int marker{0}; - int max_parts{1000}; + std::optional marker; + std::optional max_parts; uint16_t requested_attributes{0}; #if 0 /* used to decrypt attributes for objects stored with SSE-C */ diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 6cd641e5c3c6e..5269c88d94dd3 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -3835,7 +3835,7 @@ int RGWGetObjAttrs_ObjStore_S3::get_params(optional_yield y) << err << dendl; return -ERR_INVALID_PART; } - max_parts = std::min(max_parts, 1000); + max_parts = std::min(*max_parts, 1000); } hdr = env->get_optional("HTTP_X_AMZ_PART_NUMBER_MARKER"); @@ -3950,7 +3950,9 @@ void RGWGetObjAttrs_ObjStore_S3::send_response() int ret = s->object->list_parts( - this, s->cct, max_parts, marker, + this, s->cct, + max_parts ? *max_parts : 1000, + marker ? *marker : 0, &next_marker, &truncated, [&](const Object::Part& part) -> int { s->formatter->open_object_section("Part"); @@ -3972,9 +3974,15 @@ void RGWGetObjAttrs_ObjStore_S3::send_response() s->formatter->dump_int("PartsCount", *multipart_parts_count); s->formatter->dump_int("TotalPartsCount", *multipart_parts_count); s->formatter->dump_bool("IsTruncated", truncated); - s->formatter->dump_int("MaxParts", max_parts); - s->formatter->dump_int("NextPartNumberMarker", next_marker); - s->formatter->dump_int("PartNumberMarker", marker); + if (max_parts) { + s->formatter->dump_int("MaxParts", *max_parts); + } + if(truncated) { + s->formatter->dump_int("NextPartNumberMarker", next_marker); + } + if (marker) { + s->formatter->dump_int("PartNumberMarker", *marker); + } s->formatter->close_section(); } /* multipart_parts_count positive */ } /* ObjectParts */ -- 2.39.5