From: Radoslaw Zarzynski Date: Fri, 6 Mar 2015 11:42:52 +0000 (+0100) Subject: rgw: enable end_header() to handle proposal of Content-Length. X-Git-Tag: v0.80.11~66^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=84525806a057054dca295f860e0a31d6936d4985;p=ceph.git rgw: enable end_header() to handle proposal of Content-Length. Backport: hammer Signed-off-by: Radoslaw Zarzynski (cherry picked from commit f98fd4dfda7a105d621f99c2b48eb9ab9b45d979) --- diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 768ca09a476..882aefd2bb6 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -427,7 +427,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; @@ -460,6 +460,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 a6108f4e75a..71845359869 100644 --- a/src/rgw/rgw_rest.h +++ b/src/rgw/rgw_rest.h @@ -354,10 +354,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);