From e80bd0a2a39afdabcb134100e0cc8fa74cbd14c2 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 --- 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 69a8cb65ff14f..33a1e7876aa7a 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -960,6 +960,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 012f5003ee532..b519c46bfa0b3 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -53,8 +53,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); @@ -82,7 +85,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); + } } } @@ -90,6 +95,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