Project

General

Profile

Actions

Bug #8539

closed

civetweb backend responds with a body when a HEAD request yields an error

Added by Sylvain Munaut almost 10 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Target version:
-
% Done:

0%

Source:
Community (user)
Tags:
Backport:
firefly
Regression:
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

So for example, doing a HEAD on a non-existent key will yield a 404, along with a Content-Length: 79 (which is allowed), but then there should be no body at all (even with a content-length, see http specs).

Currently it will actually send a body when using the civetweb backend (it works with the fastcgi one, althouhg I don't know if it really works or if the http server actually cleans up the response ...).

I applied this fix to my tree to fix the issue. I'm not sure it's the "right fix", but it works and makes my regression test pass.

diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc
index 69948a6..b74002d 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());
   }
 }

Files

fix-for-head-body.diff (1.45 KB) fix-for-head-body.diff Patch Sylvain Munaut, 06/05/2014 12:06 PM

Related issues 1 (0 open1 closed)

Has duplicate rgw - Bug #9037: civetweb: error HEAD responses return bodyDuplicate08/07/2014

Actions
Actions #1

Updated by Yehuda Sadeh almost 10 years ago

This fix seems fine to me. Can you resend it with a proper description and a Signed-off-by line?

Actions #3

Updated by Yehuda Sadeh over 9 years ago

  • Status changed from New to Pending Backport
  • Backport set to firefly
Actions #4

Updated by Yehuda Sadeh over 9 years ago

Merged, commit:0a2b4c25541bbd15776d3d35986518e37166910f

Actions #5

Updated by Sage Weil over 9 years ago

  • Status changed from Pending Backport to Resolved
Actions

Also available in: Atom PDF