You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2015/08/10 21:58:52 UTC
trafficserver git commit: TS-3831: overridable error response type
This closes #273.
Repository: trafficserver
Updated Branches:
refs/heads/master d903a38d1 -> e985569ae
TS-3831: overridable error response type
This closes #273.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e985569a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e985569a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e985569a
Branch: refs/heads/master
Commit: e985569ae95fa6345f6302d1340d4e9b4e64b804
Parents: d903a38
Author: Syeda Persia Aziz <pe...@yahoo.com>
Authored: Fri Aug 7 16:55:29 2015 -0500
Committer: Alan M. Carroll <so...@yahoo-inc.com>
Committed: Mon Aug 10 14:40:51 2015 -0500
----------------------------------------------------------------------
lib/ts/apidefs.h.in | 1 +
mgmt/RecordsConfig.cc | 3 ++-
.../experimental/ts_lua/ts_lua_http_config.c | 5 ++--
proxy/InkAPI.cc | 24 +++++++++++++++++++-
proxy/InkAPITest.cc | 3 ++-
proxy/http/HttpBodyFactory.cc | 13 +++++++++--
proxy/http/HttpConfig.cc | 6 ++++-
proxy/http/HttpConfig.h | 8 +++++--
8 files changed, 53 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e985569a/lib/ts/apidefs.h.in
----------------------------------------------------------------------
diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
index 5058990..2237cfe 100644
--- a/lib/ts/apidefs.h.in
+++ b/lib/ts/apidefs.h.in
@@ -674,6 +674,7 @@ typedef enum {
TS_CONFIG_HTTP_AUTH_SERVER_SESSION_PRIVATE,
TS_CONFIG_HTTP_SLOW_LOG_THRESHOLD,
TS_CONFIG_HTTP_CACHE_GENERATION,
+ TS_CONFIG_BODY_FACTORY_TEMPLATE_BASE,
TS_CONFIG_LAST_ENTRY
} TSOverridableConfigKey;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e985569a/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 72e677f..fc0c6b6 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -737,7 +737,8 @@ static const RecordElement RecordsConfig[] =
//# 2 - suppress responses for intercepted 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}
+ ,
//##############################################################################
//#
//# SOCKS Processor
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e985569a/plugins/experimental/ts_lua/ts_lua_http_config.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http_config.c b/plugins/experimental/ts_lua/ts_lua_http_config.c
index bdf7a78..d3cc003 100644
--- a/plugins/experimental/ts_lua/ts_lua_http_config.c
+++ b/plugins/experimental/ts_lua/ts_lua_http_config.c
@@ -82,6 +82,7 @@ typedef enum {
TS_LUA_CONFIG_NET_SOCK_PACKET_MARK_OUT = TS_CONFIG_NET_SOCK_PACKET_MARK_OUT,
TS_LUA_CONFIG_NET_SOCK_PACKET_TOS_OUT = TS_CONFIG_NET_SOCK_PACKET_TOS_OUT,
TS_LUA_CONFIG_HTTP_SLOW_LOG_THRESHOLD = TS_CONFIG_HTTP_SLOW_LOG_THRESHOLD,
+ TS_LUA_CONFIG_BODY_FACTORY_TEMPLATE_BASE = TS_CONFIG_BODY_FACTORY_TEMPLATE_BASE,
TS_LUA_CONFIG_LAST_ENTRY = TS_CONFIG_LAST_ENTRY,
} TSLuaOverridableConfigKey;
@@ -141,8 +142,8 @@ ts_lua_var_item ts_lua_http_config_vars[] = {
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_FUZZ_MIN_TIME), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_DOC_IN_CACHE_SKIP_DNS),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_RESPONSE_SERVER_STR), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_HEURISTIC_LM_FACTOR),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_FUZZ_PROBABILITY), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_NET_SOCK_PACKET_MARK_OUT),
- TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_NET_SOCK_PACKET_TOS_OUT), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
- TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_SLOW_LOG_THRESHOLD),
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_NET_SOCK_PACKET_TOS_OUT), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_SLOW_LOG_THRESHOLD),
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_BODY_FACTORY_TEMPLATE_BASE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
};
ts_lua_var_item ts_lua_http_timeout_vars[] = {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e985569a/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 445e2ce..6c4129e 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7909,7 +7909,10 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr
typ = OVERRIDABLE_TYPE_INT;
ret = &overridableHttpConfig->slow_log_threshold;
break;
-
+ case TS_CONFIG_BODY_FACTORY_TEMPLATE_BASE:
+ typ = OVERRIDABLE_TYPE_STRING;
+ ret = &overridableHttpConfig->body_factory_template_base;
+ break;
// This helps avoiding compiler warnings, yet detect unhandled enum members.
case TS_CONFIG_NULL:
case TS_CONFIG_LAST_ENTRY:
@@ -8055,6 +8058,15 @@ TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char
s->t_state.txn_conf->global_user_agent_header_size = 0;
}
break;
+ case TS_CONFIG_BODY_FACTORY_TEMPLATE_BASE:
+ if (value && length > 0) {
+ s->t_state.txn_conf->body_factory_template_base = const_cast<char *>(value);
+ s->t_state.txn_conf->body_factory_template_base_len = length;
+ } else {
+ s->t_state.txn_conf->body_factory_template_base = NULL;
+ s->t_state.txn_conf->body_factory_template_base_len = 0;
+ }
+ break;
default:
return TS_ERROR;
break;
@@ -8082,6 +8094,10 @@ TSHttpTxnConfigStringGet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char
*value = sm->t_state.txn_conf->global_user_agent_header;
*length = sm->t_state.txn_conf->global_user_agent_header_size;
break;
+ case TS_CONFIG_BODY_FACTORY_TEMPLATE_BASE:
+ *value = sm->t_state.txn_conf->body_factory_template_base;
+ *length = sm->t_state.txn_conf->body_factory_template_base_len;
+ break;
default:
return TS_ERROR;
break;
@@ -8208,6 +8224,12 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf,
case 39:
switch (name[length - 1]) {
+ case 'e':
+ if (!strncmp(name, "proxy.config.body_factory.template_base", length)) {
+ cnf = TS_CONFIG_BODY_FACTORY_TEMPLATE_BASE;
+ typ = TS_RECORDDATATYPE_STRING;
+ }
+ break;
case 'm':
if (!strncmp(name, "proxy.config.http.anonymize_remove_from", length))
cnf = TS_CONFIG_HTTP_ANONYMIZE_REMOVE_FROM;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e985569a/proxy/InkAPITest.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 4a43fa6..704a759 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -7206,7 +7206,8 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = {
"proxy.config.ssl.hsts_max_age", "proxy.config.ssl.hsts_include_subdomains", "proxy.config.http.cache.open_read_retry_time",
"proxy.config.http.cache.max_open_read_retries", "proxy.config.http.cache.range.write",
"proxy.config.http.post.check.content_length.enabled", "proxy.config.http.global_user_agent_header",
- "proxy.config.http.auth_server_session_private", "proxy.config.http.slow.log.threshold", "proxy.config.http.cache.generation"};
+ "proxy.config.http.auth_server_session_private", "proxy.config.http.slow.log.threshold", "proxy.config.http.cache.generation",
+ "proxy.config.body_factory.template_base"};
REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus)
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e985569a/proxy/http/HttpBodyFactory.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpBodyFactory.cc b/proxy/http/HttpBodyFactory.cc
index 362b335..540f01c 100644
--- a/proxy/http/HttpBodyFactory.cc
+++ b/proxy/http/HttpBodyFactory.cc
@@ -147,6 +147,7 @@ HttpBodyFactory::fabricate_with_old_api(const char *type, HttpTransact::State *c
buffer = fabricate(&acpt_language_list, &acpt_charset_list, "default", context, resulting_buffer_length, &lang_ptr,
&charset_ptr, &set);
}
+
///////////////////////////////////
// enforce the max buffer length //
///////////////////////////////////
@@ -397,9 +398,11 @@ HttpBodyFactory::fabricate(StrList *acpt_language_list, StrList *acpt_charset_li
const char **set_return)
{
char *buffer;
+ const char *pType = context->txn_conf->body_factory_template_base;
const char *set;
HttpBodyTemplate *t;
HttpBodySet *body_set;
+ char template_base[PATH_NAME_MAX];
if (set_return)
*set_return = "???";
@@ -430,9 +433,15 @@ HttpBodyFactory::fabricate(StrList *acpt_language_list, StrList *acpt_charset_li
if (set_return)
*set_return = set;
-
+ if (pType != NULL && 0 != *pType && 0 != strncmp(pType, "NONE", 4)) {
+ sprintf(template_base, "%s_%s", pType, type);
+ } else {
+ sprintf(template_base, "%s", type);
+ }
// see if we have a custom error page template
- t = find_template(set, type, &body_set);
+ t = find_template(set, template_base, &body_set);
+ if (t == NULL)
+ t = find_template(set, type, &body_set); // this executes if the template_base is wrong and doesn't exist
if (t == NULL) {
Debug("body_factory", " can't find template, returning NULL template");
return (NULL);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e985569a/proxy/http/HttpConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 646173d..b467f2f 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -1065,7 +1065,8 @@ HttpConfig::startup()
HttpEstablishStaticConfigStringAlloc(c.reverse_proxy_no_host_redirect, "proxy.config.header.parse.no_host_url_redirect");
c.reverse_proxy_no_host_redirect_len = -1;
-
+ HttpEstablishStaticConfigStringAlloc(c.oride.body_factory_template_base, "proxy.config.body_factory.template_base");
+ c.oride.body_factory_template_base_len = c.oride.body_factory_template_base ? strlen(c.oride.body_factory_template_base) : 0;
HttpEstablishStaticConfigByte(c.errors_log_error_pages, "proxy.config.http.errors.log_error_pages");
HttpEstablishStaticConfigLongLong(c.oride.slow_log_threshold, "proxy.config.http.slow.log.threshold");
@@ -1334,6 +1335,9 @@ HttpConfig::reconfigure()
params->oride.default_buffer_size_index = m_master.oride.default_buffer_size_index;
params->oride.default_buffer_water_mark = m_master.oride.default_buffer_water_mark;
params->enable_http_info = INT_TO_BOOL(m_master.enable_http_info);
+ params->oride.body_factory_template_base = ats_strdup(m_master.oride.body_factory_template_base);
+ params->oride.body_factory_template_base_len =
+ params->oride.body_factory_template_base ? strlen(params->oride.body_factory_template_base) : 0;
params->reverse_proxy_no_host_redirect = ats_strdup(m_master.reverse_proxy_no_host_redirect);
params->reverse_proxy_no_host_redirect_len =
params->reverse_proxy_no_host_redirect ? strlen(params->reverse_proxy_no_host_redirect) : 0;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e985569a/proxy/http/HttpConfig.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index cd2cb75..1722f74 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -386,8 +386,9 @@ struct OverridableHttpConfigParams {
default_buffer_size_index(8), default_buffer_water_mark(32768), slow_log_threshold(0),
// Strings / floats must come last
- proxy_response_server_string(NULL), proxy_response_server_string_len(0), global_user_agent_header(NULL),
- global_user_agent_header_size(0), cache_heuristic_lm_factor(0.10), freshness_fuzz_prob(0.005), background_fill_threshold(0.5)
+ body_factory_template_base(NULL), body_factory_template_base_len(0), proxy_response_server_string(NULL),
+ proxy_response_server_string_len(0), global_user_agent_header(NULL), global_user_agent_header_size(0),
+ cache_heuristic_lm_factor(0.10), freshness_fuzz_prob(0.005), background_fill_threshold(0.5)
{
}
@@ -561,6 +562,8 @@ struct OverridableHttpConfigParams {
///////////////////////////////////////////////////////////////////
// Server header //
///////////////////////////////////////////////////////////////////
+ char *body_factory_template_base;
+ size_t body_factory_template_base_len;
char *proxy_response_server_string; // This does not get free'd by us!
size_t proxy_response_server_string_len; // Updated when server_string is set.
@@ -866,6 +869,7 @@ inline HttpConfigParams::~HttpConfigParams()
ats_free(proxy_response_via_string);
ats_free(url_expansions_string);
ats_free(anonymize_other_header_list);
+ ats_free(oride.body_factory_template_base);
ats_free(oride.proxy_response_server_string);
ats_free(oride.global_user_agent_header);
ats_free(cache_vary_default_text);