]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: If the client sends a Connection: close header respond accordingly. 5213/head
authorWido den Hollander <wido@42on.com>
Fri, 10 Jul 2015 22:01:52 +0000 (00:01 +0200)
committerWido den Hollander <wido@42on.com>
Mon, 13 Jul 2015 10:56:57 +0000 (12:56 +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
src/rgw/rgw_civetweb.cc
src/rgw/rgw_civetweb.h

index 827709b993b342cfb5613b43231589d080607588..eea3b1459bd7f245c789d8559d42c4cc5b3a1a64 100644 (file)
@@ -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");
 
index 291132885955626df7777188f835576bbb29af42..1cee5c8b59f0521ce1df27a097a04443b81bde3c 100644 (file)
@@ -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);