From 009664e560ee37ef6dc170a0155d6c749e151b06 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Tue, 21 Apr 2015 12:31:19 +0200 Subject: [PATCH] rgw: force content-type header for swift account responses without body This regression was introduced in commit 4cfeca03ade21861ab70ca759f94eb244c16cb39 Fixes: #11438 Signed-off-by: Orit Wasserman --- src/rgw/rgw_rest.cc | 5 +++-- src/rgw/rgw_rest.h | 3 ++- src/rgw/rgw_rest_swift.cc | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index dabfc5200714..9e1f049b851b 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -494,7 +494,8 @@ void dump_start(struct req_state *s) } } -void end_header(struct req_state *s, RGWOp *op, const char *content_type, const int64_t proposed_content_length) +void end_header(struct req_state *s, RGWOp *op, const char *content_type, const int64_t proposed_content_length, + bool force_content_type) { string ctype; @@ -504,7 +505,7 @@ void end_header(struct req_state *s, RGWOp *op, const char *content_type, const /* do not send content type if content length is zero and the content type was not set by the user */ - if ((s->formatter->get_len() != 0 && !content_type) || s->err.is_err()){ + if (force_content_type || (!content_type && s->formatter->get_len() != 0) || s->err.is_err()){ switch (s->format) { case RGW_FORMAT_XML: ctype = "application/xml"; diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index c92a59a81848..02ae790edaab 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -365,7 +365,8 @@ extern void dump_errno(struct req_state *s, int ret); extern void end_header(struct req_state *s, RGWOp *op = NULL, const char *content_type = NULL, - const int64_t proposed_content_length = NO_CONTENT_LENGTH); + const int64_t proposed_content_length = NO_CONTENT_LENGTH, + bool force_content_type = false); extern void dump_start(struct req_state *s); extern void list_all_buckets_start(struct req_state *s); extern void dump_owner(struct req_state *s, string& id, string& name, const char *section = NULL); diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 182a4a3e3dd1..f28227158001 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -80,7 +80,7 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets) /* 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); dump_errno(s); - end_header(s, NULL); + end_header(s, NULL, NULL, true); if (!ret) { dump_start(s); @@ -307,7 +307,8 @@ void RGWStatAccount_ObjStore_SWIFT::send_response() set_req_state_err(s, ret); dump_errno(s); - end_header(s, NULL, NULL, 0); + end_header(s, NULL, NULL, 0, true); + dump_start(s); } -- 2.47.3