This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 27fd544 Traffic Dump: Add server response HTTP version (#6856) 27fd544 is described below commit 27fd54423e40305083a3e74dd77f0e3e974be32f Author: Brian Neradt <brian.ner...@gmail.com> AuthorDate: Fri Jun 12 17:03:02 2020 -0500 Traffic Dump: Add server response HTTP version (#6856) Co-authored-by: bneradt <bner...@verizonmedia.com> (cherry picked from commit 85d28d9a9b66b9ddd9535eab1cd9c6c8eda0c8e5) --- plugins/experimental/traffic_dump/transaction_data.cc | 17 +++++++++-------- tests/tools/lib/replay_schema.json | 7 ++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/plugins/experimental/traffic_dump/transaction_data.cc b/plugins/experimental/traffic_dump/transaction_data.cc index 4951f2f..b87a8c6 100644 --- a/plugins/experimental/traffic_dump/transaction_data.cc +++ b/plugins/experimental/traffic_dump/transaction_data.cc @@ -118,12 +118,14 @@ TransactionData::write_message_node_no_content(TSMBuffer &buffer, TSMLoc &hdr_lo char const *cp = nullptr; TSMLoc url_loc = nullptr; + // 1. "version" + // Note that we print this for both requests and responses, so the first + // element in each has to start with a comma. + int version = TSHttpHdrVersionGet(buffer, hdr_loc); + result += R"("version":")" + std::to_string(TS_HTTP_MAJOR(version)) + "." + std::to_string(TS_HTTP_MINOR(version)) + '"'; + // Log scheme+method+request-target or status+reason based on header type if (TSHttpHdrTypeGet(buffer, hdr_loc) == TS_HTTP_TYPE_REQUEST) { - // 1. "version" - int version = TSHttpHdrVersionGet(buffer, hdr_loc); - result += R"("version":")" + std::to_string(TS_HTTP_MAJOR(version)) + "." + std::to_string(TS_HTTP_MINOR(version)) + '"'; - TSAssert(TS_SUCCESS == TSHttpHdrUrlGet(buffer, hdr_loc, &url_loc)); // 2. "scheme": cp = TSUrlSchemeGet(buffer, url_loc, &len); @@ -156,12 +158,11 @@ TransactionData::write_message_node_no_content(TSMBuffer &buffer, TSMLoc &hdr_lo TSfree(url); TSHandleMLocRelease(buffer, hdr_loc, url_loc); } else { - // 1. "status":(string) - result += R"("status":)" + std::to_string(TSHttpHdrStatusGet(buffer, hdr_loc)); - // 2. "reason":(string) + // 2. "status":(string) + result += R"(,"status":)" + std::to_string(TSHttpHdrStatusGet(buffer, hdr_loc)); + // 3. "reason":(string) cp = TSHttpHdrReasonGet(buffer, hdr_loc, &len); result += "," + traffic_dump::json_entry("reason", cp, len); - // 3. "encoding" } // "headers": [[name(string), value(string)]] diff --git a/tests/tools/lib/replay_schema.json b/tests/tools/lib/replay_schema.json index 328c13d..35906f4 100644 --- a/tests/tools/lib/replay_schema.json +++ b/tests/tools/lib/replay_schema.json @@ -157,7 +157,7 @@ "version": { "description": "HTTP version", "type": "string", - "enum": ["0.9", "1.0", "1.1"] + "enum": ["0.9", "1.0", "1.1", "2.0"] }, "scheme": { "description": "HTTP scheme (request).", @@ -187,6 +187,11 @@ "type": "object", "required": ["status"], "properties": { + "version": { + "description": "HTTP version", + "type": "string", + "enum": ["0.9", "1.0", "1.1", "2.0"] + }, "status": { "description": "Status code.", "type": "number"