This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit a380ddd907b19797f5e3a7ad0f35e38bae18c793 Author: Randall Meyer <[email protected]> AuthorDate: Wed Apr 25 17:26:30 2018 -0700 Adds log field for "reason phrase" returned with status codes reason sometimes has more detail about why a request failed than the status code or the result code (crc) `prrp`: HTTP response reason phrase sent to client (cherry picked from commit 21953ef5ff01bd050a3b3c43e2a5fdd6156a045d) --- doc/admin-guide/logging/formatting.en.rst | 3 +++ proxy/logging/Log.cc | 5 +++++ proxy/logging/LogAccess.cc | 5 +++++ proxy/logging/LogAccess.h | 1 + proxy/logging/LogAccessHttp.cc | 16 ++++++++++++++++ proxy/logging/LogAccessHttp.h | 3 +++ proxy/logging/LogAccessTest.cc | 14 ++++++++++++++ proxy/logging/LogAccessTest.h | 1 + 8 files changed, 48 insertions(+) diff --git a/doc/admin-guide/logging/formatting.en.rst b/doc/admin-guide/logging/formatting.en.rst index bbb3150..4a1379c 100644 --- a/doc/admin-guide/logging/formatting.en.rst +++ b/doc/admin-guide/logging/formatting.en.rst @@ -561,6 +561,7 @@ Status Codes .. _pfsc: .. _pssc: .. _sssc: +.. _prrp: These log fields provide a variety of status codes, some numeric and some as strings, relating to client, proxy, and origin transactions. @@ -577,6 +578,8 @@ pfsc Proxy Request Finish status code specifying whether the proxy request from |TS| to the origin server was successfully completed (``FIN``), interrupted (``INTR``), or timed out (``TIMEOUT``). +prrp Proxy Response HTTP response reason phrase sent by |TS| proxy to the + client. pssc Proxy Response HTTP response status code sent by |TS| proxy to the client. sssc Origin Response HTTP response status code sent by the origin server diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc index 9e06443..4955608 100644 --- a/proxy/logging/Log.cc +++ b/proxy/logging/Log.cc @@ -544,6 +544,11 @@ Log::init_fields() global_field_list.add(field, false); ink_hash_table_insert(field_symbol_hash, "psct", field); + field = new LogField("proxy_resp_reason_phrase", "prrp", LogField::STRING, &LogAccess::marshal_proxy_resp_reason_phrase, + (LogField::UnmarshalFunc)&LogAccess::unmarshal_str); + global_field_list.add(field, false); + ink_hash_table_insert(field_symbol_hash, "prrp", field); + field = new LogField("proxy_resp_squid_len", "psql", LogField::sINT, &LogAccess::marshal_proxy_resp_squid_len, &LogAccess::unmarshal_int_to_str); global_field_list.add(field, false); diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc index 144d82a..55fe7d6 100644 --- a/proxy/logging/LogAccess.cc +++ b/proxy/logging/LogAccess.cc @@ -224,6 +224,11 @@ LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_resp_content_type, DEFAULT_STR_FIELD) /*------------------------------------------------------------------------- -------------------------------------------------------------------------*/ +LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_resp_reason_phrase, DEFAULT_STR_FIELD) + +/*------------------------------------------------------------------------- + -------------------------------------------------------------------------*/ + LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_resp_squid_len, DEFAULT_INT_FIELD) LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_squid_len, DEFAULT_INT_FIELD) LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_req_squid_len, DEFAULT_INT_FIELD) diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h index 0d410e3..fb45b55 100644 --- a/proxy/logging/LogAccess.h +++ b/proxy/logging/LogAccess.h @@ -200,6 +200,7 @@ public: // proxy -> client fields // inkcoreapi virtual int marshal_proxy_resp_content_type(char *); // STR + inkcoreapi virtual int marshal_proxy_resp_reason_phrase(char *); // STR inkcoreapi virtual int marshal_proxy_resp_squid_len(char *); // INT inkcoreapi virtual int marshal_proxy_resp_content_len(char *); // INT inkcoreapi virtual int marshal_proxy_resp_status_code(char *); // INT diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc index 404f65b..8cd0add 100644 --- a/proxy/logging/LogAccessHttp.cc +++ b/proxy/logging/LogAccessHttp.cc @@ -70,6 +70,8 @@ LogAccessHttp::LogAccessHttp(HttpSM *sm) m_client_req_url_path_len(0), m_proxy_resp_content_type_str(nullptr), m_proxy_resp_content_type_len(0), + m_proxy_resp_reason_phrase_str(nullptr), + m_proxy_resp_reason_phrase_len(0), m_cache_lookup_url_canon_str(nullptr), m_cache_lookup_url_canon_len(-1) { @@ -137,6 +139,7 @@ LogAccessHttp::init() LogUtils::remove_content_type_attributes(m_proxy_resp_content_type_str, &m_proxy_resp_content_type_len); } } + m_proxy_resp_reason_phrase_str = (char *)m_proxy_response->reason_get(&m_proxy_resp_reason_phrase_len); } if (hdr->server_request.valid()) { m_proxy_request = &(hdr->server_request); @@ -856,6 +859,19 @@ LogAccessHttp::marshal_proxy_resp_content_type(char *buf) } /*------------------------------------------------------------------------- + -------------------------------------------------------------------------*/ + +int +LogAccessHttp::marshal_proxy_resp_reason_phrase(char *buf) +{ + int len = round_strlen(m_proxy_resp_reason_phrase_len + 1); + if (buf) { + marshal_mem(buf, m_proxy_resp_reason_phrase_str, m_proxy_resp_reason_phrase_len, len); + } + return len; +} + +/*------------------------------------------------------------------------- Squid returns the content-length + header length as the total length. -------------------------------------------------------------------------*/ diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h index ef679b9..f78fe3a 100644 --- a/proxy/logging/LogAccessHttp.h +++ b/proxy/logging/LogAccessHttp.h @@ -87,6 +87,7 @@ public: // proxy -> client fields // int marshal_proxy_resp_content_type(char *) override; // STR + int marshal_proxy_resp_reason_phrase(char *) override; // STR int marshal_proxy_resp_header_len(char *) override; // INT int marshal_proxy_resp_content_len(char *) override; // INT int marshal_proxy_resp_squid_len(char *) override; // INT @@ -200,6 +201,8 @@ private: int m_client_req_url_path_len; char *m_proxy_resp_content_type_str; int m_proxy_resp_content_type_len; + char *m_proxy_resp_reason_phrase_str; + int m_proxy_resp_reason_phrase_len; char *m_cache_lookup_url_canon_str; int m_cache_lookup_url_canon_len; diff --git a/proxy/logging/LogAccessTest.cc b/proxy/logging/LogAccessTest.cc index 56cba48..ebcba6d 100644 --- a/proxy/logging/LogAccessTest.cc +++ b/proxy/logging/LogAccessTest.cc @@ -196,6 +196,20 @@ LogAccessTest::marshal_proxy_resp_content_type(char *buf) -------------------------------------------------------------------------*/ int +LogAccessTest::marshal_proxy_resp_reason_phrase(char *buf) +{ + static char const *str = "Unknown reason"; + int len = LogAccess::strlen(str); + if (buf) { + marshal_str(buf, str, len); + } + return len; +} + +/*------------------------------------------------------------------------- + -------------------------------------------------------------------------*/ + +int LogAccessTest::marshal_proxy_resp_squid_len(char *buf) { if (buf) { diff --git a/proxy/logging/LogAccessTest.h b/proxy/logging/LogAccessTest.h index fd7635a..ead97e7 100644 --- a/proxy/logging/LogAccessTest.h +++ b/proxy/logging/LogAccessTest.h @@ -61,6 +61,7 @@ public: // proxy -> client fields // virtual int marshal_proxy_resp_content_type(char *); // STR + virtual int marshal_proxy_resp_reason_phrase(char *); // STR virtual int marshal_proxy_resp_squid_len(char *); // INT virtual int marshal_proxy_resp_content_len(char *); // INT virtual int marshal_proxy_resp_status_code(char *); // INT -- To stop receiving notification emails like this one, please contact [email protected].
