From: Radoslaw Zarzynski Date: Wed, 18 Feb 2015 14:48:43 +0000 (+0100) Subject: rgw: generate the "Date" HTTP header for civetweb. X-Git-Tag: v9.0.0~225^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F3761%2Fhead;p=ceph.git rgw: generate the "Date" HTTP header for civetweb. Fixes: #10873 Backport: hammer Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc index 901b2ded8ac6..1495e92d4741 100644 --- a/src/rgw/rgw_civetweb.cc +++ b/src/rgw/rgw_civetweb.cc @@ -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(>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; @@ -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"); diff --git a/src/rgw/rgw_civetweb.h b/src/rgw/rgw_civetweb.h index 9a7594fe8fb6..291132885955 100644 --- a/src/rgw/rgw_civetweb.h +++ b/src/rgw/rgw_civetweb.h @@ -3,6 +3,7 @@ #ifndef CEPH_RGW_MONGOOSE_H #define CEPH_RGW_MONGOOSE_H +#define TIME_BUF_SIZE 128 #include "rgw_client_io.h"