]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: use GMT time format defined by RFC1123 in http request header
authorlvshanchun <lvshanchun@gmail.com>
Thu, 23 Nov 2017 08:41:44 +0000 (16:41 +0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 12 Apr 2018 22:38:36 +0000 (15:38 -0700)
Signed-off-by: lvshanchun <lvshanchun@gmail.com>
src/rgw/rgw_rest_client.cc

index 4a8dcd1b437e74d9ac2a0eafe771348b6666df15..e1d0dfe5f1366b853d81a5c0e3b52da77d108706 100644 (file)
@@ -104,6 +104,20 @@ static void get_new_date_str(string& date_str)
   date_str = rgw_to_asctime(ceph_clock_now());
 }
 
+static void get_gmt_date_str(string& date_str)
+{
+  auto now_time = ceph::real_clock::now();
+  time_t rawtime = ceph::real_clock::to_time_t(now_time);
+
+  char buffer[80];
+
+  struct tm timeInfo;
+  gmtime_r(&rawtime, &timeInfo);
+  strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S %z", &timeInfo);  
+  
+  date_str = buffer;
+}
+
 int RGWRESTSimpleRequest::execute(RGWAccessKey& key, const char *_method, const char *resource)
 {
   method = _method;
@@ -431,7 +445,7 @@ void RGWRESTStreamS3PutObj::send_init(rgw_obj& obj)
     new_url.append("/");
 
   string date_str;
-  get_new_date_str(date_str);
+  get_gmt_date_str(date_str);
 
   string params_str;
   map<string, string>& args = new_info.args.get_params();
@@ -588,7 +602,7 @@ int RGWRESTStreamRWRequest::send_prepare(RGWAccessKey *key, map<string, string>&
     new_url.append("/");
 
   string date_str;
-  get_new_date_str(date_str);
+  get_gmt_date_str(date_str);
 
   RGWEnv new_env;
   req_info new_info(cct, &new_env);