]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: enable end_header() to handle proposal of Content-Length.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 6 Mar 2015 11:42:52 +0000 (12:42 +0100)
committerLoic Dachary <ldachary@redhat.com>
Wed, 6 May 2015 12:03:26 +0000 (14:03 +0200)
Backport: hammer
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
(cherry picked from commit f98fd4dfda7a105d621f99c2b48eb9ab9b45d979)

src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h

index 93f5b3f0b26c480e3e97e9e9fc79cfc00196c2ae..601a265ac144a1c5e7437c1153efbd22ca5c8f64 100644 (file)
@@ -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) {
index a6b680b2e846fbf75b07383a0b79dd2a220eefe9..0779fdde07fae37692564c838a771f0486100404 100644 (file)
@@ -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);