From: Sylvain Munaut Date: Thu, 5 Jun 2014 09:28:27 +0000 (+0200) Subject: rgw: Don't send error body when it's a HEAD request X-Git-Tag: v0.80.6~94 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fc1a4b5fdce7b92ba1b321dec37c4c75501e3521;p=ceph.git rgw: Don't send error body when it's a HEAD request 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 Signed-off-by: Sylvain Munaut (cherry picked from commit 0a2b4c25541bbd15776d3d35986518e37166910f) --- diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 69948a6735bf..b74002de1e71 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -180,7 +180,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()); } @@ -192,7 +192,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()); } }