]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rest: don't require s->formatter
authorCasey Bodley <cbodley@redhat.com>
Mon, 13 Mar 2023 19:53:32 +0000 (15:53 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 13 Mar 2023 19:53:32 +0000 (15:53 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rest.cc

index d37afff526a4b30b0ad5f7a35a46e6b5a26df929..872ede1d9d46bffc195d251beea87b86a9663043 100644 (file)
@@ -287,7 +287,9 @@ static bool rgw_find_host_in_domains(const string& host, string *domain, string
 static void dump_status(req_state *s, int status,
                        const char *status_name)
 {
-  s->formatter->set_status(status, status_name);
+  if (s->formatter) {
+    s->formatter->set_status(status, status_name);
+  }
   try {
     RESTFUL_IO(s)->send_status(status, status_name);
   } catch (rgw::io::Exception& e) {
@@ -593,8 +595,8 @@ void end_header(req_state* s, RGWOp* op, const char *content_type,
 
   /* do not send content type if content length is zero
      and the content type was not set by the user */
-  if (force_content_type ||
-      (!content_type &&  s->formatter->get_len()  != 0) || s->is_err()){
+  if (force_content_type || s->is_err() ||
+      (!content_type && s->formatter && s->formatter->get_len() != 0)) {
     ctype = to_mime_type(s->format);
     if (s->prot_flags & RGW_REST_SWIFT)
       ctype.append("; charset=utf-8");
@@ -603,7 +605,7 @@ void end_header(req_state* s, RGWOp* op, const char *content_type,
   if (!force_no_error && s->is_err()) {
     dump_start(s);
     dump(s);
-    dump_content_length(s, s->formatter->get_len());
+    dump_content_length(s, s->formatter ? s->formatter->get_len() : 0);
   } else {
     if (proposed_content_length == CHUNKED_TRANSFER_ENCODING) {
       dump_chunked_encoding(s);
@@ -625,7 +627,9 @@ void end_header(req_state* s, RGWOp* op, const char *content_type,
   }
 
   ACCOUNTING_IO(s)->set_account(true);
-  rgw_flush_formatter_and_reset(s, s->formatter);
+  if (s->formatter) {
+    rgw_flush_formatter_and_reset(s, s->formatter);
+  }
 }
 
 static void build_redirect_url(req_state *s, const string& redirect_base, string *redirect_url)