You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/04/09 18:15:10 UTC
[trafficserver] branch 9.0.x updated: Support body factory template
suppression for internal requests
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 66a2910 Support body factory template suppression for internal requests
66a2910 is described below
commit 66a291073b072058d8b79009e269d9c084a9c8b4
Author: Sudheer Vinukonda <su...@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)
(cherry picked from commit 3a0cdb202c9f680416c194cadecd95c0d90b8cb2)
---
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 da61549..2fe3bf2 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -2379,7 +2379,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 13169c5..efdbdc0 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;
}