]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: If the client sends a Connection: close header respond accordingly. 5284/head
authorWido den Hollander <wido@42on.com>
Fri, 10 Jul 2015 22:01:52 +0000 (00:01 +0200)
committerNathan Cutler <ncutler@suse.com>
Sun, 19 Jul 2015 15:57:17 +0000 (17:57 +0200)
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
src/rgw/rgw_civetweb.h

index 901b2ded8ac692c8ef1fea3234e5b281c5199c32..cd5ad6362bb80567f5bf9c73b12490c58e51e88d 100644 (file)
@@ -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");
 
index 9a7594fe8fb6330eac34814dbdf0a27c2fee1c38..f469b78df4bce619d70e60182285f7963e14069d 100644 (file)
@@ -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);