From 6829ee29a484a3b7055122addcda06a233d3ce53 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Thu, 25 Jun 2015 18:28:50 +0200 Subject: [PATCH] rgw: send Content-Length in response for GET on Swift account. Fixes: #12158 Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 5f47b11791cd46ce2771046e4888575869cc9685) Conflicts: src/rgw/rgw_rest_swift.cc omit dump_account_metadata() call --- src/common/config_opts.h | 1 + src/rgw/rgw_rest_swift.cc | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 315ac82c5e577..ee8fc9de0195a 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -789,6 +789,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 a89c5d0b669e2..4e4475a8ffb9c 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -51,8 +51,11 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets) ret = STATUS_NO_CONTENT; set_req_state_err(s, ret); } - dump_errno(s); - end_header(s, NULL, NULL, true); + + if (!g_conf->rgw_swift_enforce_content_length) { + dump_errno(s); + end_header(s, NULL, NULL, NO_CONTENT_LENGTH, true); + } if (!ret) { dump_start(s); @@ -79,7 +82,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); + } } } @@ -87,6 +92,14 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_end() { if (sent_data) { s->formatter->close_section(); + } + + if (g_conf->rgw_swift_enforce_content_length) { + 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); } } -- 2.39.5