]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: generate the "Date" HTTP header for civetweb. 5228/head
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 18 Feb 2015 14:48:43 +0000 (15:48 +0100)
committerAbhishek Lekshmanan <abhishek.lekshmanan@ril.com>
Tue, 14 Jul 2015 08:30:36 +0000 (14:00 +0530)
Fixes: #10873
Backport: hammer
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
(cherry picked from commit ea384f83b601f60e135c3d3f960fdb75a919dd84)

src/rgw/rgw_civetweb.cc
src/rgw/rgw_civetweb.h

index 901b2ded8ac692c8ef1fea3234e5b281c5199c32..1495e92d4741f3cd057b4c3c127dbf185516924e 100644 (file)
@@ -147,6 +147,20 @@ int RGWMongoose::send_100_continue()
   return mg_write(conn, buf, sizeof(buf) - 1);
 }
 
+static void dump_date_header(bufferlist &out)
+{
+  char timestr[TIME_BUF_SIZE];
+  const time_t gtime = time(NULL);
+  struct tm result;
+  struct tm const * const tmp = gmtime_r(&gtime, &result);
+
+  if (tmp == NULL)
+    return;
+
+  if (strftime(timestr, sizeof(timestr), "Date: %a, %d %b %Y %H:%M:%S %Z\r\n", tmp))
+    out.append(timestr);
+}
+
 int RGWMongoose::complete_header()
 {
   header_done = true;
@@ -155,6 +169,8 @@ int RGWMongoose::complete_header()
     return 0;
   }
 
+  dump_date_header(header_data);
+
   if (explicit_keepalive)
     header_data.append("Connection: Keep-Alive\r\n");
 
index 9a7594fe8fb6330eac34814dbdf0a27c2fee1c38..291132885955626df7777188f835576bbb29af42 100644 (file)
@@ -3,6 +3,7 @@
 
 #ifndef CEPH_RGW_MONGOOSE_H
 #define CEPH_RGW_MONGOOSE_H
+#define TIME_BUF_SIZE 128
 
 #include "rgw_client_io.h"