From: Jiaying Ren Date: Thu, 10 Aug 2017 07:21:32 +0000 (+0800) Subject: rgw: fix opslog uri as per Amazon s3 X-Git-Tag: v13.0.1~487^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=96bb12a158ab899ec219d88e140499a4e27b4ba5;p=ceph.git rgw: fix opslog uri as per Amazon s3 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 Signed-off-by: Jiaying Ren --- diff --git a/src/rgw/rgw_asio_client.cc b/src/rgw/rgw_asio_client.cc index 63de2d27e75..5fa40a9680b 100644 --- a/src/rgw/rgw_asio_client.cc +++ b/src/rgw/rgw_asio_client.cc @@ -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 diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc index 110a891ca92..f4d17d721c1 100644 --- a/src/rgw/rgw_civetweb.cc +++ b/src/rgw/rgw_civetweb.cc @@ -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) { diff --git a/src/rgw/rgw_log.cc b/src/rgw/rgw_log.cc index b8378174ee8..2930abb9af8 100644 --- a/src/rgw/rgw_log.cc +++ b/src/rgw/rgw_log.cc @@ -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 */