Merge pull request #3761 from rzarzynski/wip-10873

rgw: generate the "Date" HTTP header.

Reviewed-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
Yehuda Sadeh 2015-03-02 10:50:42 -08:00
commit 522a8f99fe
2 changed files with 17 additions and 0 deletions

View 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");

View 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"