]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Don't send error body when it's a HEAD request
authorSylvain Munaut <s.munaut@whatever-company.com>
Thu, 5 Jun 2014 09:28:27 +0000 (11:28 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 11 Aug 2014 19:36:05 +0000 (12:36 -0700)
The main 'operation' know not to send any body for HEAD requests.

However for errors, this was not the case, the formatter would be
flushed and would send the error 'message' in the body in all cases.

For the FastCGI case it doesn't seem to be an issue, it's possible
that the webserver (apache/lighttpd/...) cleans up the response
into shape.

But when using the new civetweb frontend this cause invalid HTTP.

Backport: firefly
Fixes #8539

Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Signed-off-by: Sylvain Munaut <s.munaut@whatever-company.com>
src/rgw/rgw_rest.cc

index aba9d58b19396626a4cd0c3303af6afa41aae4de..bc2b97e07c028e06feb0bbb72d4fec2788eaaf4e 100644 (file)
@@ -183,7 +183,7 @@ void rgw_flush_formatter_and_reset(struct req_state *s, Formatter *formatter)
   std::ostringstream oss;
   formatter->flush(oss);
   std::string outs(oss.str());
-  if (!outs.empty()) {
+  if (!outs.empty() && s->op != OP_HEAD) {
     s->cio->write(outs.c_str(), outs.size());
   }
 
@@ -195,7 +195,7 @@ void rgw_flush_formatter(struct req_state *s, Formatter *formatter)
   std::ostringstream oss;
   formatter->flush(oss);
   std::string outs(oss.str());
-  if (!outs.empty()) {
+  if (!outs.empty() && s->op != OP_HEAD) {
     s->cio->write(outs.c_str(), outs.size());
   }
 }