Repository: trafficserver Updated Branches: refs/heads/master 0be393be8 -> f2ba1dc71
[TS-3994] Configurable option to allow redirect follow to use original request cache key. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f2ba1dc7 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f2ba1dc7 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f2ba1dc7 Branch: refs/heads/master Commit: f2ba1dc71cd68bf7a98c87a3e1f19b131899847f Parents: 0be393b Author: Sudheer Vinukonda <[email protected]> Authored: Thu Nov 5 18:55:44 2015 +0000 Committer: Sudheer Vinukonda <[email protected]> Committed: Thu Nov 5 18:55:44 2015 +0000 ---------------------------------------------------------------------- lib/ts/apidefs.h.in | 1 + mgmt/RecordsConfig.cc | 5 ++++- plugins/experimental/ts_lua/ts_lua_http_config.c | 4 +++- proxy/InkAPI.cc | 8 ++++++++ proxy/InkAPITest.cc | 2 +- proxy/http/HttpConfig.cc | 16 ++++++++++------ proxy/http/HttpConfig.h | 3 ++- proxy/http/HttpSM.cc | 2 +- 8 files changed, 30 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2ba1dc7/lib/ts/apidefs.h.in ---------------------------------------------------------------------- diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in index 6dba244..e8acced 100644 --- a/lib/ts/apidefs.h.in +++ b/lib/ts/apidefs.h.in @@ -692,6 +692,7 @@ typedef enum { TS_CONFIG_HTTP_ENABLE_REDIRECTION, TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS, TS_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES, + TS_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY, TS_CONFIG_LAST_ENTRY } TSOverridableConfigKey; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2ba1dc7/mgmt/RecordsConfig.cc ---------------------------------------------------------------------- diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 144d4c1..1a37264 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -169,13 +169,16 @@ static const RecordElement RecordsConfig[] = //# //# 1. redirection_enabled: if set to 1, redirection is enabled. //# 2. number_of_redirectionse: The maximum number of redirections TS permits - //# 3. post_copy_size: The maximum POST data size TS permits to copy + //# 3. proxy.config.http.redirect_use_orig_cache_key: Location Header if set to 0 (default), else use original request cache key + //# 4. post_copy_size: The maximum POST data size TS permits to copy //# //############################################################################## {RECT_CONFIG, "proxy.config.http.redirection_enabled", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL} , {RECT_CONFIG, "proxy.config.http.number_of_redirections", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL} , + {RECT_CONFIG, "proxy.config.http.redirect_use_orig_cache_key", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL} + , {RECT_CONFIG, "proxy.config.http.redirect_host_no_port", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL} , {RECT_CONFIG, "proxy.config.http.post_copy_size", RECD_INT, "2048", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL} http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2ba1dc7/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 ae2658b..50cf14c 100644 --- a/plugins/experimental/ts_lua/ts_lua_http_config.c +++ b/plugins/experimental/ts_lua/ts_lua_http_config.c @@ -112,6 +112,7 @@ typedef enum { TS_LUA_CONFIG_HTTP_ENABLE_REDIRECTION = TS_CONFIG_HTTP_ENABLE_REDIRECTION, TS_LUA_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS = TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS, TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES = TS_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES, + TS_LUA_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY = TS_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY, TS_LUA_CONFIG_LAST_ENTRY = TS_CONFIG_LAST_ENTRY, } TSLuaOverridableConfigKey; @@ -194,7 +195,8 @@ ts_lua_var_item ts_lua_http_config_vars[] = { TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_GENERATION), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_BODY_FACTORY_TEMPLATE_BASE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_OPEN_WRITE_FAIL_ACTION), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_ENABLE_REDIRECTION), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS), - TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY), + TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES), + TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY), }; // Needed to make sure we have the latest list of overridable http config vars when compiling http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2ba1dc7/proxy/InkAPI.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 2c6a946..8373e16 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -7976,6 +7976,10 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr typ = OVERRIDABLE_TYPE_INT; ret = &overridableHttpConfig->number_of_redirections; break; + case TS_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY: + typ = OVERRIDABLE_TYPE_INT; + ret = &overridableHttpConfig->redirect_use_orig_cache_key; + break; // This helps avoiding compiler warnings, yet detect unhandled enum members. case TS_CONFIG_NULL: case TS_CONFIG_LAST_ENTRY: @@ -8466,6 +8470,10 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf, if (0 == strncmp(name, "proxy.config.http.auth_server_session_private", length)) cnf = TS_CONFIG_HTTP_AUTH_SERVER_SESSION_PRIVATE; break; + case 'y': + if (!strncmp(name, "proxy.config.http.redirect_use_orig_cache_key", length)) + cnf = TS_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY; + break; } break; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2ba1dc7/proxy/InkAPITest.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc index 4be5099..f8944f8 100644 --- a/proxy/InkAPITest.cc +++ b/proxy/InkAPITest.cc @@ -7210,7 +7210,7 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = { "proxy.config.http.auth_server_session_private", "proxy.config.http.slow.log.threshold", "proxy.config.http.cache.generation", "proxy.config.body_factory.template_base", "proxy.config.http.cache.open_write_fail_action", "proxy.config.http.redirection_enabled", "proxy.config.http.number_of_redirections", - "proxy.config.http.cache.max_open_write_retries"}; + "proxy.config.http.cache.max_open_write_retries", "proxy.config.http.redirect_use_orig_cache_key"}; REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2ba1dc7/proxy/http/HttpConfig.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index 6cc56c9..5a94fcb 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -1102,12 +1102,14 @@ HttpConfig::startup() //# Redirection //# //# 1. redirection_enabled: if set to 1, redirection is enabled. - //# 2. number_of_redirections: The maximum number of redirections YTS permits - //# 3. post_copy_size: The maximum POST data size YTS permits to copy - //# 4. redirection_host_no_port: do not include default port in host header during redirection + //# 2. redirect_use_orig_cache_key: if set to 1, use original request cache key. + //# 3. number_of_redirections: The maximum number of redirections YTS permits + //# 4. post_copy_size: The maximum POST data size YTS permits to copy + //# 5. redirection_host_no_port: do not include default port in host header during redirection //# //############################################################################## HttpEstablishStaticConfigByte(c.oride.redirection_enabled, "proxy.config.http.redirection_enabled"); + HttpEstablishStaticConfigByte(c.oride.redirect_use_orig_cache_key, "proxy.config.http.redirect_use_orig_cache_key"); HttpEstablishStaticConfigByte(c.redirection_host_no_port, "proxy.config.http.redirect_host_no_port"); HttpEstablishStaticConfigLongLong(c.oride.number_of_redirections, "proxy.config.http.number_of_redirections"); HttpEstablishStaticConfigLongLong(c.post_copy_size, "proxy.config.http.post_copy_size"); @@ -1360,13 +1362,15 @@ HttpConfig::reconfigure() //# Redirection //# //# 1. redirection_enabled: if set to 1, redirection is enabled. - //# 2. number_of_redirections: The maximum number of redirections YTS permits - //# 3. post_copy_size: The maximum POST data size YTS permits to copy - //# 4. redirection_host_no_port: do not include default port in host header during redirection + //# 2. redirect_use_orig_cache_key: if set to 1, use original request cache key. + //# 3. number_of_redirections: The maximum number of redirections YTS permits + //# 4. post_copy_size: The maximum POST data size YTS permits to copy + //# 5. redirection_host_no_port: do not include default port in host header during redirection //# //############################################################################## params->oride.redirection_enabled = INT_TO_BOOL(m_master.oride.redirection_enabled); + params->oride.redirect_use_orig_cache_key = INT_TO_BOOL(m_master.oride.redirect_use_orig_cache_key); params->redirection_host_no_port = INT_TO_BOOL(m_master.redirection_host_no_port); params->oride.number_of_redirections = m_master.oride.number_of_redirections; params->post_copy_size = m_master.post_copy_size; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2ba1dc7/proxy/http/HttpConfig.h ---------------------------------------------------------------------- diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index f6fdda6..5f99cbd 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -389,7 +389,7 @@ struct OverridableHttpConfigParams { 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), cache_open_write_fail_action(0), - redirection_enabled(0), number_of_redirections(1) + redirection_enabled(0), redirect_use_orig_cache_key(0), number_of_redirections(1) { } @@ -593,6 +593,7 @@ struct OverridableHttpConfigParams { //############################################################################## MgmtByte redirection_enabled; + MgmtByte redirect_use_orig_cache_key; MgmtInt number_of_redirections; }; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f2ba1dc7/proxy/http/HttpSM.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 02b4ff3..188aef5 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -4394,7 +4394,7 @@ HttpSM::do_cache_lookup_and_read() // Changed the lookup_url to c_url which enables even // the new redirect url to perform a CACHE_LOOKUP URL *c_url; - if (t_state.redirect_info.redirect_in_process) + if (t_state.redirect_info.redirect_in_process && !t_state.txn_conf->redirect_use_orig_cache_key) c_url = t_state.hdr_info.client_request.url_get(); else c_url = t_state.cache_info.lookup_url;
