]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw:attrs: dump marker and max_parts only if sent
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 18 Oct 2024 19:50:14 +0000 (15:50 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 8 Jan 2025 00:17:54 +0000 (19:17 -0500)
Suggested by Casey.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_op.h
src/rgw/rgw_rest_s3.cc

index d3980bc718315c904460db0325e689abda0d4cee..7ab956b7b9e51be9cddfd554b577c58c3df59993 100644 (file)
@@ -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<int> marker;
+  std::optional<int> max_parts;
   uint16_t requested_attributes{0};
 #if 0
   /* used to decrypt attributes for objects stored with SSE-C */
index 6cd641e5c3c6e7f6c0a21d19d4d767c8afd94dc6..5269c88d94dd3eafc2265a554e488cf562845895 100644 (file)
@@ -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 */