Repository: trafficserver Updated Branches: refs/heads/master f06382e46 -> 0662db401
[TS-3893]: Make redirect follow settings overridable. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0662db40 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0662db40 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0662db40 Branch: refs/heads/master Commit: 0662db401e45af039872b9118f3947509cb20e96 Parents: f06382e Author: Sudheer Vinukonda <[email protected]> Authored: Fri Sep 4 18:03:19 2015 +0000 Committer: Sudheer Vinukonda <[email protected]> Committed: Fri Sep 4 18:03:19 2015 +0000 ---------------------------------------------------------------------- lib/ts/apidefs.h.in | 10 +++--- .../experimental/ts_lua/ts_lua_http_config.c | 7 +++- proxy/InkAPI.cc | 17 ++++++++- proxy/InkAPITest.cc | 3 +- proxy/http/HttpConfig.cc | 8 ++--- proxy/http/HttpConfig.h | 36 +++++++++++--------- proxy/http/HttpSM.cc | 10 +++--- 7 files changed, 58 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0662db40/lib/ts/apidefs.h.in ---------------------------------------------------------------------- diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in index b6c4bb7..f086b08 100644 --- a/lib/ts/apidefs.h.in +++ b/lib/ts/apidefs.h.in @@ -75,10 +75,10 @@ extern "C" { /* Version info */ #define TS_VERSION_STRING "@TS_VERSION_STRING@" -#define TS_VERSION_NUMBER @TS_VERSION_NUMBER@ -#define TS_VERSION_MAJOR @TS_VERSION_MAJOR@ -#define TS_VERSION_MINOR @TS_VERSION_MINOR@ -#define TS_VERSION_MICRO @TS_VERSION_MICRO@ +#define TS_VERSION_NUMBER @TS_VERSION_NUMBER @ +#define TS_VERSION_MAJOR @TS_VERSION_MAJOR @ +#define TS_VERSION_MINOR @TS_VERSION_MINOR @ +#define TS_VERSION_MICRO @TS_VERSION_MICRO @ #define TS_HTTP_VERSION(a, b) ((((a)&0xFFFF) << 16) | ((b)&0xFFFF)) #define TS_HTTP_MINOR(v) ((v)&0xFFFF) @@ -676,6 +676,8 @@ typedef enum { TS_CONFIG_HTTP_CACHE_GENERATION, TS_CONFIG_BODY_FACTORY_TEMPLATE_BASE, TS_CONFIG_HTTP_CACHE_OPEN_WRITE_FAIL_ACTION, + TS_CONFIG_HTTP_ENABLE_REDIRECTION, + TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS, TS_CONFIG_LAST_ENTRY } TSOverridableConfigKey; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0662db40/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 d3cc003..0f07c26 100644 --- a/plugins/experimental/ts_lua/ts_lua_http_config.c +++ b/plugins/experimental/ts_lua/ts_lua_http_config.c @@ -83,6 +83,9 @@ typedef enum { 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_OPEN_WRITE_FAIL_ACTION = TS_CONFIG_HTTP_CACHE_OPEN_WRITE_FAIL_ACTION, + 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_LAST_ENTRY = TS_CONFIG_LAST_ENTRY, } TSLuaOverridableConfigKey; @@ -143,7 +146,9 @@ ts_lua_var_item ts_lua_http_config_vars[] = { 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_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_MAKE_VAR_ITEM(TS_LUA_CONFIG_BODY_FACTORY_TEMPLATE_BASE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_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_LAST_ENTRY), }; ts_lua_var_item ts_lua_http_timeout_vars[] = { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0662db40/proxy/InkAPI.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 65c5ba0..923ae29 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -7268,7 +7268,7 @@ TSRedirectUrlSet(TSHttpTxn txnp, const char *url, const int url_len) sm->enable_redirection = true; // max-out "redirection_tries" to avoid the regular redirection being turned on in // this transaction improperly. This variable doesn't affect the custom-redirection - sm->redirection_tries = HttpConfig::m_master.number_of_redirections; + sm->redirection_tries = sm->t_state.txn_conf->number_of_redirections; } } @@ -7929,6 +7929,14 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr typ = OVERRIDABLE_TYPE_STRING; ret = &overridableHttpConfig->body_factory_template_base; break; + case TS_CONFIG_HTTP_ENABLE_REDIRECTION: + typ = OVERRIDABLE_TYPE_INT; + ret = &overridableHttpConfig->redirection_enabled; + break; + case TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS: + typ = OVERRIDABLE_TYPE_INT; + ret = &overridableHttpConfig->number_of_redirections; + break; // This helps avoiding compiler warnings, yet detect unhandled enum members. case TS_CONFIG_NULL: case TS_CONFIG_LAST_ENTRY: @@ -8197,6 +8205,11 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf, case 37: switch (name[length - 1]) { + case 'd': + if (!strncmp(name, "proxy.config.http.redirection_enabled", length)) { + cnf = TS_CONFIG_HTTP_ENABLE_REDIRECTION; + } + break; case 'e': if (!strncmp(name, "proxy.config.http.cache.max_stale_age", length)) cnf = TS_CONFIG_HTTP_CACHE_MAX_STALE_AGE; @@ -8284,6 +8297,8 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf, cnf = TS_CONFIG_HTTP_CACHE_REQUIRED_HEADERS; else if (!strncmp(name, "proxy.config.ssl.hsts_include_subdomains", length)) cnf = TS_CONFIG_SSL_HSTS_INCLUDE_SUBDOMAINS; + else if (!strncmp(name, "proxy.config.http.number_of_redirections", length)) + cnf = TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS; break; case 't': if (!strncmp(name, "proxy.config.http.keep_alive_enabled_out", length)) http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0662db40/proxy/InkAPITest.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc index 5fefdb3..968e990 100644 --- a/proxy/InkAPITest.cc +++ b/proxy/InkAPITest.cc @@ -7207,7 +7207,8 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = { "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.body_factory.template_base", "proxy.config.http.cache.open_write_fail_action"}; + "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"}; REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0662db40/proxy/http/HttpConfig.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index e45739c..96fe448 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -1107,9 +1107,9 @@ HttpConfig::startup() //# 4. redirection_host_no_port: do not include default port in host header during redirection //# //############################################################################## - HttpEstablishStaticConfigByte(c.redirection_enabled, "proxy.config.http.redirection_enabled"); + HttpEstablishStaticConfigByte(c.oride.redirection_enabled, "proxy.config.http.redirection_enabled"); HttpEstablishStaticConfigByte(c.redirection_host_no_port, "proxy.config.http.redirect_host_no_port"); - HttpEstablishStaticConfigLongLong(c.number_of_redirections, "proxy.config.http.number_of_redirections"); + HttpEstablishStaticConfigLongLong(c.oride.number_of_redirections, "proxy.config.http.number_of_redirections"); HttpEstablishStaticConfigLongLong(c.post_copy_size, "proxy.config.http.post_copy_size"); // Local Manager @@ -1366,9 +1366,9 @@ HttpConfig::reconfigure() //# //############################################################################## - params->redirection_enabled = INT_TO_BOOL(m_master.redirection_enabled); + params->oride.redirection_enabled = INT_TO_BOOL(m_master.oride.redirection_enabled); params->redirection_host_no_port = INT_TO_BOOL(m_master.redirection_host_no_port); - params->number_of_redirections = m_master.number_of_redirections; + params->oride.number_of_redirections = m_master.oride.number_of_redirections; params->post_copy_size = m_master.post_copy_size; // Local Manager http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0662db40/proxy/http/HttpConfig.h ---------------------------------------------------------------------- diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index c963361..62cc4a4 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -388,7 +388,8 @@ struct OverridableHttpConfigParams { // Strings / floats must come last 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) + 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) { } @@ -577,6 +578,19 @@ struct OverridableHttpConfigParams { MgmtFloat freshness_fuzz_prob; MgmtFloat background_fill_threshold; MgmtInt cache_open_write_fail_action; + + //############################################################################## + //# + //# Redirection + //# + //# 1. redirection_enabled: if set to 1, redirection is enabled. + //# 2. number_of_redirectionse: The maximum number of redirections YTS permits + //# 3. post_copy_size: The maximum POST data size YTS permits to copy + //# + //############################################################################## + + MgmtByte redirection_enabled; + MgmtInt number_of_redirections; }; @@ -719,19 +733,7 @@ public: // rather it is the time skew which the manager observes int32_t cluster_time_delta; - //############################################################################## - //# - //# Redirection - //# - //# 1. redirection_enabled: if set to 1, redirection is enabled. - //# 2. number_of_redirectionse: The maximum number of redirections YTS permits - //# 3. post_copy_size: The maximum POST data size YTS permits to copy - //# - //############################################################################## - - MgmtByte redirection_enabled; MgmtByte redirection_host_no_port; - MgmtInt number_of_redirections; MgmtInt post_copy_size; ////////////////////////////////////////////////////////////////// @@ -854,10 +856,10 @@ inline HttpConfigParams::HttpConfigParams() cache_vary_default_other(NULL), max_cache_open_write_retries(1), cache_enable_default_vary_headers(0), cache_post_method(0), connect_ports_string(NULL), connect_ports(NULL), push_method_enabled(0), referer_filter_enabled(0), referer_format_redirect(0), reverse_proxy_enabled(0), url_remap_required(1), record_cop_page(0), errors_log_error_pages(1), enable_http_info(0), - cluster_time_delta(0), redirection_enabled(0), redirection_host_no_port(1), number_of_redirections(1), post_copy_size(2048), - ignore_accept_mismatch(0), ignore_accept_language_mismatch(0), ignore_accept_encoding_mismatch(0), - ignore_accept_charset_mismatch(0), send_100_continue_response(0), disallow_post_100_continue(0), parser_allow_non_http(1), - max_post_size(0), server_session_sharing_pool(TS_SERVER_SESSION_SHARING_POOL_THREAD), synthetic_port(0) + cluster_time_delta(0), redirection_host_no_port(1), post_copy_size(2048), ignore_accept_mismatch(0), + ignore_accept_language_mismatch(0), ignore_accept_encoding_mismatch(0), ignore_accept_charset_mismatch(0), + send_100_continue_response(0), disallow_post_100_continue(0), parser_allow_non_http(1), max_post_size(0), + server_session_sharing_pool(TS_SERVER_SESSION_SHARING_POOL_THREAD), synthetic_port(0) { } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0662db40/proxy/http/HttpSM.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 4fce169..df369d8 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -761,9 +761,9 @@ HttpSM::state_read_client_request_header(int event, void *data) } // YTS Team, yamsat Plugin // Setting enable_redirection according to HttpConfig master - if ((HttpConfig::m_master.number_of_redirections > 0) || + if ((t_state.txn_conf->number_of_redirections > 0) || (t_state.method == HTTP_WKSIDX_POST && HttpConfig::m_master.post_copy_size)) - enable_redirection = HttpConfig::m_master.redirection_enabled; + enable_redirection = t_state.txn_conf->redirection_enabled; call_transact_and_set_next_state(HttpTransact::ModifyRequest); @@ -1851,7 +1851,7 @@ HttpSM::state_read_server_response_header(int event, void *data) t_state.api_next_action = HttpTransact::SM_ACTION_API_READ_RESPONSE_HDR; // if exceeded limit deallocate postdata buffers and disable redirection - if (enable_redirection && (redirection_tries < HttpConfig::m_master.number_of_redirections)) { + if (enable_redirection && (redirection_tries < t_state.txn_conf->number_of_redirections)) { ++redirection_tries; } else { tunnel.deallocate_redirect_postdata_buffers(); @@ -7379,7 +7379,7 @@ void HttpSM::do_redirect() { DebugSM("http_redirect", "[HttpSM::do_redirect]"); - if (!enable_redirection || redirection_tries >= HttpConfig::m_master.number_of_redirections) { + if (!enable_redirection || redirection_tries >= t_state.txn_conf->number_of_redirections) { tunnel.deallocate_redirect_postdata_buffers(); return; } @@ -7682,7 +7682,7 @@ HttpSM::is_private() inline bool HttpSM::is_redirect_required() { - bool redirect_required = (enable_redirection && (redirection_tries <= HttpConfig::m_master.number_of_redirections)); + bool redirect_required = (enable_redirection && (redirection_tries <= t_state.txn_conf->number_of_redirections)); DebugSM("http_redirect", "is_redirect_required %u", redirect_required);
