From: Radoslaw Zarzynski Date: Thu, 25 Jun 2015 16:28:50 +0000 (+0200) Subject: rgw: send Content-Length in response for GET on Swift account. X-Git-Tag: v9.0.3~51^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5f47b11791cd46ce2771046e4888575869cc9685;p=ceph.git rgw: send Content-Length in response for GET on Swift account. Fixes: #12158 Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 93bb608f7e33..f91baffea115 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -972,6 +972,7 @@ OPTION(rgw_swift_url_prefix, OPT_STR, "swift") // entry point for which a url is OPTION(rgw_swift_auth_url, OPT_STR, "") // default URL to go and verify tokens for v1 auth (if not using internal swift auth) OPTION(rgw_swift_auth_entry, OPT_STR, "auth") // entry point for which a url is considered a swift auth url OPTION(rgw_swift_tenant_name, OPT_STR, "") // tenant name to use for swift access +OPTION(rgw_swift_enforce_content_length, OPT_BOOL, false) // enforce generation of Content-Length even in cost of performance or scalability OPTION(rgw_keystone_url, OPT_STR, "") // url for keystone server OPTION(rgw_keystone_admin_token, OPT_STR, "") // keystone admin token (shared secret) OPTION(rgw_keystone_admin_user, OPT_STR, "") // keystone admin user name diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 242a7d9e992a..2f9b44c5efb5 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -105,10 +105,18 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets) ret = STATUS_NO_CONTENT; set_req_state_err(s, ret); } - /* Adding account stats in the header to keep align with Swift API */ - dump_account_metadata(s, buckets_count, buckets_objcount, buckets_size, buckets_size_rounded, attrs); - dump_errno(s); - end_header(s, NULL, NULL, NO_CONTENT_LENGTH, true); + + if (!g_conf->rgw_swift_enforce_content_length) { + /* Adding account stats in the header to keep align with Swift API */ + dump_account_metadata(s, + buckets_count, + buckets_objcount, + buckets_size, + buckets_size_rounded, + attrs); + dump_errno(s); + end_header(s, NULL, NULL, NO_CONTENT_LENGTH, true); + } if (!ret) { dump_start(s); @@ -135,7 +143,9 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_data(RGWUserBuckets& buckets) s->formatter->dump_int("bytes", obj.size); } s->formatter->close_section(); - rgw_flush_formatter(s, s->formatter); + if (!g_conf->rgw_swift_enforce_content_length) { + rgw_flush_formatter(s, s->formatter); + } } } @@ -143,6 +153,21 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_end() { if (sent_data) { s->formatter->close_section(); + } + + if (g_conf->rgw_swift_enforce_content_length) { + /* Adding account stats in the header to keep align with Swift API */ + dump_account_metadata(s, + buckets_count, + buckets_objcount, + buckets_size, + buckets_size_rounded, + attrs); + dump_errno(s); + end_header(s, NULL, NULL, s->formatter->get_len(), true); + } + + if (sent_data || g_conf->rgw_swift_enforce_content_length) { rgw_flush_formatter_and_reset(s, s->formatter); } }