From: Wido den Hollander Date: Fri, 10 Jul 2015 22:01:52 +0000 (+0200) Subject: rgw: If the client sends a Connection: close header respond accordingly. X-Git-Tag: v9.0.3~41^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F5213%2Fhead;p=ceph.git rgw: If the client sends a Connection: close header respond accordingly. HTTP/1.1 assumes Keep-Alive by default, but if a Connection: close header is send the server should respond with it as well. This makes the client close the connection after the request. Fixes: #12298 --- diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc index 827709b993b3..eea3b1459bd7 100644 --- a/src/rgw/rgw_civetweb.cc +++ b/src/rgw/rgw_civetweb.cc @@ -28,7 +28,7 @@ int RGWMongoose::write_data(const char *buf, int len) } RGWMongoose::RGWMongoose(mg_connection *_conn, int _port) : conn(_conn), port(_port), header_done(false), sent_header(false), has_content_length(false), - explicit_keepalive(false) + explicit_keepalive(false), explicit_conn_close(false) { } @@ -93,6 +93,7 @@ void RGWMongoose::init_env(CephContext *cct) if (strcasecmp(header->name, "connection") == 0) { explicit_keepalive = (strcasecmp(header->value, "keep-alive") == 0); + explicit_conn_close = (strcasecmp(header->value, "close") == 0); } int len = strlen(header->name) + 5; /* HTTP_ prepended */ @@ -178,6 +179,8 @@ int RGWMongoose::complete_header() if (explicit_keepalive) header_data.append("Connection: Keep-Alive\r\n"); + else if (explicit_conn_close) + header_data.append("Connection: close\r\n"); header_data.append("\r\n"); diff --git a/src/rgw/rgw_civetweb.h b/src/rgw/rgw_civetweb.h index 291132885955..1cee5c8b59f0 100644 --- a/src/rgw/rgw_civetweb.h +++ b/src/rgw/rgw_civetweb.h @@ -24,6 +24,7 @@ class RGWMongoose : public RGWClientIO bool sent_header; bool has_content_length; bool explicit_keepalive; + bool explicit_conn_close; public: void init_env(CephContext *cct);