]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: shouldn't return content-type: application/xml if content length is 0
authorOrit Wasserman <owasserm@redhat.com>
Thu, 9 Apr 2015 18:04:59 +0000 (20:04 +0200)
committerLoic Dachary <ldachary@redhat.com>
Thu, 3 Sep 2015 11:28:50 +0000 (13:28 +0200)
Fixed: #11091

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
(cherry picked from commit 5cc92bb27cfbaee4af24dc312c9b98331f899794)

src/rgw/rgw_rest.cc

index 5f4c40043118e1c7968c235ef2d7ca74a583209c..6873bd1086d829ce6007c8245a486d24d5d2d617 100644 (file)
@@ -512,7 +512,9 @@ void end_header(struct req_state *s, RGWOp *op, const char *content_type, const
     dump_access_control(s, op);
   }
 
-  if (!content_type || s->err.is_err()) {
+  /* 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()){
     switch (s->format) {
     case RGW_FORMAT_XML:
       ctype = "application/xml";
@@ -542,9 +544,13 @@ void end_header(struct req_state *s, RGWOp *op, const char *content_type, const
       dump_content_length(s, proposed_content_length);
     }
   }
-  int r = s->cio->print("Content-type: %s\r\n", content_type);
-  if (r < 0) {
-    ldout(s->cct, 0) << "ERROR: s->cio->print() returned err=" << r << dendl;
+
+  int r;
+  if (content_type) {
+      r = s->cio->print("Content-type: %s\r\n", content_type);
+      if (r < 0) {
+       ldout(s->cct, 0) << "ERROR: s->cio->print() returned err=" << r << dendl;
+      }
   }
   r = s->cio->complete_header();
   if (r < 0) {