From 99301384be96997203682679c0430ca0a53be5d3 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 18 Feb 2015 15:48:43 +0100 Subject: [PATCH] rgw: generate the "Date" HTTP header for civetweb. Fixes: #10873 Backport: hammer Signed-off-by: Radoslaw Zarzynski (cherry picked from commit ea384f83b601f60e135c3d3f960fdb75a919dd84) --- src/rgw/rgw_civetweb.cc | 16 ++++++++++++++++ src/rgw/rgw_civetweb.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc index b44a40c2dd02..7f246d15c26d 100644 --- a/src/rgw/rgw_civetweb.cc +++ b/src/rgw/rgw_civetweb.cc @@ -145,6 +145,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(>ime, &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; @@ -153,6 +167,8 @@ int RGWMongoose::complete_header() return 0; } + dump_date_header(header_data); + if (explicit_keepalive) header_data.append("Connection: Keep-Alive\r\n"); diff --git a/src/rgw/rgw_civetweb.h b/src/rgw/rgw_civetweb.h index c1df9f08a5bb..f50d5d6f225c 100644 --- a/src/rgw/rgw_civetweb.h +++ b/src/rgw/rgw_civetweb.h @@ -1,5 +1,6 @@ #ifndef CEPH_RGW_MONGOOSE_H #define CEPH_RGW_MONGOOSE_H +#define TIME_BUF_SIZE 128 #include "rgw_client_io.h" -- 2.47.3