From 54b62904a4cc3913be23803734fa68741a3c33cc Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Fri, 6 Mar 2015 12:42:52 +0100 Subject: [PATCH] rgw: enable end_header() to handle proposal of Content-Length. Backport: hammer Signed-off-by: Radoslaw Zarzynski (cherry picked from commit f98fd4dfda7a105d621f99c2b48eb9ab9b45d979) --- src/rgw/rgw_rest.cc | 6 +++++- src/rgw/rgw_rest.h | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 93f5b3f0b26c4..601a265ac144a 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -492,7 +492,7 @@ void dump_start(struct req_state *s) } } -void end_header(struct req_state *s, RGWOp *op, const char *content_type) +void end_header(struct req_state *s, RGWOp *op, const char *content_type, const int64_t proposed_content_length) { string ctype; @@ -525,6 +525,10 @@ void end_header(struct req_state *s, RGWOp *op, const char *content_type) s->formatter->dump_string("Message", s->err.message); s->formatter->close_section(); dump_content_length(s, s->formatter->get_len()); + } else { + if (proposed_content_length != NO_CONTENT_LENGTH) { + dump_content_length(s, proposed_content_length); + } } int r = s->cio->print("Content-type: %s\r\n", content_type); if (r < 0) { diff --git a/src/rgw/rgw_rest.h b/src/rgw/rgw_rest.h index a6b680b2e846f..0779fdde07fae 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -357,10 +357,15 @@ public: } }; +static const int64_t NO_CONTENT_LENGTH = -1; + extern void set_req_state_err(struct req_state *s, int err_no); extern void dump_errno(struct req_state *s); 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); +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); 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); -- 2.39.5