From 57f8b28330eab283d78e6d633866441f0e343472 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 29 Sep 2017 23:09:03 -0700 Subject: [PATCH] ircd: Add X-IRCd-Response-Time header. --- ircd/resource.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ircd/resource.cc b/ircd/resource.cc index 520db20a2..2c8c871de 100644 --- a/ircd/resource.cc +++ b/ircd/resource.cc @@ -446,7 +446,13 @@ ircd::resource::response::response(client &client, { const auto request_time { - client.request_timer.at() + client.request_timer.at().count() + }; + + char rtime[64]; const auto rtime_len + { + snprintf(rtime, sizeof(rtime), "%zdus", + request_time) }; http::response @@ -454,16 +460,17 @@ ircd::resource::response::response(client &client, code, str, write_closure(client), { { "Content-Type", content_type }, - { "Access-Control-Allow-Origin", "*" } //TODO: XXX + { "Access-Control-Allow-Origin", "*" }, //TODO: XXX + { "X-IRCd-Request-Timer", string_view{rtime, size_t(rtime_len)} } } }; log::debug("client[%s] HTTP %d %s in %ld$us; response in %ld$us (%s) content-length: %zu", - string(remote_addr(client)), + string(remote(client)), int(code), - http::reason[code], - request_time.count(), - (client.request_timer.at() - request_time).count(), + http::status(code), + request_time, + (client.request_timer.at().count() - request_time), content_type, str.size()); }