From 2357b6c808f4f7c5997af48149585a6051c04b8f Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Sat, 11 Jul 2015 00:01:52 +0200 Subject: [PATCH] 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 (cherry picked from commit 79197d3711edc4b04a7ea4335b6e1b65754996d5) --- src/rgw/rgw_civetweb.cc | 5 ++++- src/rgw/rgw_civetweb.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc index 901b2ded8ac69..cd5ad6362bb80 100644 --- a/src/rgw/rgw_civetweb.cc +++ b/src/rgw/rgw_civetweb.cc @@ -23,7 +23,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) { } @@ -88,6 +88,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 */ @@ -157,6 +158,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 9a7594fe8fb63..f469b78df4bce 100644 --- a/src/rgw/rgw_civetweb.h +++ b/src/rgw/rgw_civetweb.h @@ -23,6 +23,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); -- 2.39.5