]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix opslog uri as per Amazon s3 16958/head
authorJiaying Ren <jiaying.ren@umcloud.com>
Thu, 10 Aug 2017 07:21:32 +0000 (15:21 +0800)
committerJiaying Ren <jiaying.ren@umcloud.com>
Tue, 17 Oct 2017 06:07:48 +0000 (14:07 +0800)
According to s3[1], current Request-URI opslog entry are missing:

+ request method
+ query string
+ http version number

[1] http://docs.aws.amazon.com/AmazonS3/latest/dev/LogFormat.html

Fixes: http://tracker.ceph.com/issues/20971
Reported-by: Zhang Shaowen <zhangshaowen@cmss.chinamobile.com>
Signed-off-by: Jiaying Ren <jiaying.ren@umcloud.com>
src/rgw/rgw_asio_client.cc
src/rgw/rgw_civetweb.cc
src/rgw/rgw_log.cc

index 63de2d27e757802aed3856f2badedd6d27107868..5fa40a9680bc9c7a894c81371a95409f7de5d914 100644 (file)
@@ -63,6 +63,11 @@ void ClientIO::init_env(CephContext *cct)
     env.set(buf, value);
   }
 
+  int major = request.version / 10;
+  int minor = request.version % 10;
+  std::string http_version = std::to_string(major) + '.' + std::to_string(minor);
+  env.set("HTTP_VERSION", http_version);
+
   env.set("REQUEST_METHOD", request.method);
 
   // split uri from query
index 110a891ca9229925064e587a9cd9aaf2c67a000e..f4d17d721c18d5308504f21540d16727dbe93891 100644 (file)
@@ -112,6 +112,7 @@ void RGWCivetWeb::init_env(CephContext *cct)
 
   env.set("REMOTE_ADDR", info->remote_addr);
   env.set("REQUEST_METHOD", info->request_method);
+  env.set("HTTP_VERSION", info->http_version);
   env.set("REQUEST_URI", info->request_uri); // get the full uri, we anyway handle abs uris later
   env.set("SCRIPT_URI", info->uri); /* FIXME */
   if (info->query_string) {
index b8378174ee878e088aed71ec57e0c6f7a03a6eeb..2930abb9af8127045532c7b6147ad7c90972c79c 100644 (file)
@@ -356,7 +356,23 @@ int rgw_log_op(RGWRados *store, RGWREST* const rest, struct req_state *s,
     set_param_str(s, "HTTP_REFERRER", entry.referrer);
   else
     set_param_str(s, "HTTP_REFERER", entry.referrer);
-  set_param_str(s, "REQUEST_URI", entry.uri);
+
+  std::string uri(s->info.env->get("REQUEST_METHOD"));
+  uri.append(" ");
+
+  uri.append(s->info.env->get("REQUEST_URI"));
+  const char* qs = s->info.env->get("QUERY_STRING");
+  if(qs && (*qs != '\0')) {
+    uri.append("?");
+    uri.append(qs);
+  }
+
+  uri.append(" ");
+  uri.append("HTTP/");
+  uri.append(s->info.env->get("HTTP_VERSION"));
+
+  entry.uri = std::move(uri);
+
   set_param_str(s, "REQUEST_METHOD", entry.op);
 
   /* custom header logging */