This is an automated email from the ASF dual-hosted git repository. sudheerv pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new 3a0cdb2 Support body factory template suppression for internal requests 3a0cdb2 is described below commit 3a0cdb202c9f680416c194cadecd95c0d90b8cb2 Author: Sudheer Vinukonda <sudhe...@apache.org> AuthorDate: Tue Mar 24 15:27:26 2020 -0700 Support body factory template suppression for internal requests Repurpose unused config proxy.config.body_factory.response_suppression_mode (2) --- doc/admin-guide/files/records.config.en.rst | 2 +- mgmt/RecordsConfig.cc | 2 +- proxy/http/HttpBodyFactory.cc | 26 +++++++++++--------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index fe163d3..f5b11e4 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -2395,7 +2395,7 @@ Customizable User Response Pages ===== ====================================================================== ``0`` Never suppress generated response pages. ``1`` Always suppress generated response pages. - ``2`` Suppress response pages only for intercepted traffic. + ``2`` Suppress response pages only for internal traffic. ===== ====================================================================== .. ts:cv:: CONFIG proxy.config.http_ui_enabled INT 0 diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 24cbc3c..a7f7cb2 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -674,7 +674,7 @@ static const RecordElement RecordsConfig[] = , //# 0 - never suppress generated responses //# 1 - always suppress generated responses - //# 2 - suppress responses for intercepted traffic + //# 2 - suppress responses for internal traffic {RECT_CONFIG, "proxy.config.body_factory.response_suppression_mode", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-2]", RECA_NULL} , {RECT_CONFIG, "proxy.config.body_factory.template_base", RECD_STRING, "NONE", RECU_DYNAMIC, RR_NULL, RECC_STR, ".*", RECA_NULL} diff --git a/proxy/http/HttpBodyFactory.cc b/proxy/http/HttpBodyFactory.cc index a13d06d..4622cda 100644 --- a/proxy/http/HttpBodyFactory.cc +++ b/proxy/http/HttpBodyFactory.cc @@ -73,6 +73,16 @@ HttpBodyFactory::fabricate_with_old_api(const char *type, HttpTransact::State *c bool found_requested_template = false; bool plain_flag = false; + /////////////////////////////////////////////// + // if suppressing this response, return NULL // + /////////////////////////////////////////////// + if (is_response_suppressed(context)) { + if (enable_logging) { + Log::error("BODY_FACTORY: suppressing '%s' response for url '%s'", type, url); + } + return nullptr; + } + lock(); *resulting_buffer_length = 0; @@ -99,16 +109,6 @@ HttpBodyFactory::fabricate_with_old_api(const char *type, HttpTransact::State *c } } } - /////////////////////////////////////////////// - // if suppressing this response, return NULL // - /////////////////////////////////////////////// - if (is_response_suppressed(context)) { - if (enable_logging) { - Log::error("BODY_FACTORY: suppressing '%s' response for url '%s'", type, url); - } - unlock(); - return nullptr; - } ////////////////////////////////////////////////////////////////////////////////// // if language-targeting activated, get client Accept-Language & Accept-Charset // ////////////////////////////////////////////////////////////////////////////////// @@ -673,11 +673,7 @@ HttpBodyFactory::is_response_suppressed(HttpTransact::State *context) } else if (response_suppression_mode == 1) { return true; } else if (response_suppression_mode == 2) { - if (context->req_flavor == HttpTransact::REQ_FLAVOR_INTERCEPTED) { - return true; - } else { - return false; - } + return context->request_data.internal_txn; } else { return false; }