Repository: trafficserver Updated Branches: refs/heads/master 1062922c2 -> 4b656da0c
[TS-3394]: Return an error on a non-http response Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/d5a91db5 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/d5a91db5 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/d5a91db5 Branch: refs/heads/master Commit: d5a91db5a4906ba53a51b5b9b679706886919fa0 Parents: 1062922 Author: Sudheer Vinukonda <[email protected]> Authored: Wed Feb 18 17:48:42 2015 +0000 Committer: Sudheer Vinukonda <[email protected]> Committed: Wed Feb 18 17:48:42 2015 +0000 ---------------------------------------------------------------------- mgmt/RecordsConfig.cc | 2 ++ proxy/hdrs/HTTP.cc | 5 ++++- proxy/hdrs/HTTP.h | 1 + proxy/http/HttpConfig.cc | 2 ++ proxy/http/HttpConfig.h | 2 ++ proxy/http/HttpSM.cc | 1 + 6 files changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d5a91db5/mgmt/RecordsConfig.cc ---------------------------------------------------------------------- diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index dc3b9d2..575c374 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -358,6 +358,8 @@ static const RecordElement RecordsConfig[] = // ########### {RECT_CONFIG, "proxy.config.header.parse.no_host_url_redirect", RECD_STRING, NULL, RECU_DYNAMIC, RR_NULL, RECC_STR, ".*", RECA_NULL} , + {RECT_CONFIG, "proxy.config.http.parse.allow_non_http", RECD_INT, "1", RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL} + , //############################################################################## //# http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d5a91db5/proxy/hdrs/HTTP.cc ---------------------------------------------------------------------- diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc index 28d33d0..f2f5184 100644 --- a/proxy/hdrs/HTTP.cc +++ b/proxy/hdrs/HTTP.cc @@ -1287,7 +1287,10 @@ http_parser_parse_resp(HTTPParser *parser, HdrHeap *heap, HTTPHdrImpl *hh, const eoh: *start = old_start; - return PARSE_DONE; + if (parser->m_allow_non_http) + return PARSE_DONE; + else + return PARSE_ERROR; done: if (!version_start || !version_end) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d5a91db5/proxy/hdrs/HTTP.h ---------------------------------------------------------------------- diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h index fa0281d..b686f3c 100644 --- a/proxy/hdrs/HTTP.h +++ b/proxy/hdrs/HTTP.h @@ -339,6 +339,7 @@ struct HTTPValTE struct HTTPParser { bool m_parsing_http; + bool m_allow_non_http; MIMEParser m_mime_parser; }; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d5a91db5/proxy/http/HttpConfig.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index b0e5904..ab560d3 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -1289,6 +1289,7 @@ HttpConfig::startup() HttpEstablishStaticConfigByte(c.send_100_continue_response, "proxy.config.http.send_100_continue_response"); HttpEstablishStaticConfigByte(c.send_408_post_timeout_response, "proxy.config.http.send_408_post_timeout_response"); + HttpEstablishStaticConfigByte(c.parser_allow_non_http, "proxy.config.http.parse.allow_non_http"); HttpEstablishStaticConfigByte(c.oride.cache_when_to_revalidate, "proxy.config.http.cache.when_to_revalidate"); HttpEstablishStaticConfigByte(c.oride.cache_required_headers, "proxy.config.http.cache.required_headers"); @@ -1546,6 +1547,7 @@ HttpConfig::reconfigure() params->send_100_continue_response = INT_TO_BOOL(m_master.send_100_continue_response); params->send_408_post_timeout_response = INT_TO_BOOL(m_master.send_408_post_timeout_response); + params->parser_allow_non_http = INT_TO_BOOL(m_master.parser_allow_non_http); params->oride.cache_when_to_revalidate = m_master.oride.cache_when_to_revalidate; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d5a91db5/proxy/http/HttpConfig.h ---------------------------------------------------------------------- diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index 03644d8..9722144 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -733,6 +733,7 @@ public: MgmtByte send_100_continue_response; MgmtByte send_408_post_timeout_response; + MgmtByte parser_allow_non_http; OverridableHttpConfigParams oride; @@ -888,6 +889,7 @@ HttpConfigParams::HttpConfigParams() ignore_accept_charset_mismatch(0), send_100_continue_response(0), send_408_post_timeout_response(0), + parser_allow_non_http(1), autoconf_port(0), autoconf_localhost_only(0) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d5a91db5/proxy/http/HttpSM.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 34d0d05..6ea1b96 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -425,6 +425,7 @@ HttpSM::init() t_state.force_dns = (ip_rule_in_CacheControlTable() || t_state.parent_params->ParentTable->ipMatch || !(t_state.txn_conf->doc_in_cache_skip_dns) || !(t_state.txn_conf->cache_http)); + http_parser.m_allow_non_http = t_state.http_config_param->parser_allow_non_http; http_parser_init(&http_parser); SET_HANDLER(&HttpSM::main_handler);
