From: Adam Dickmeiss Date: Thu, 18 Jul 2013 09:14:26 +0000 (+0200) Subject: Ruleset functional MP-469 X-Git-Tag: v1.3.60~9 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=a8b25eb1e4dee0290182ca69fe49a01557c58811;p=metaproxy-moved-to-github.git Ruleset functional MP-469 --- diff --git a/src/filter_http_rewrite.cpp b/src/filter_http_rewrite.cpp index 9ef4de2..def74b1 100644 --- a/src/filter_http_rewrite.cpp +++ b/src/filter_http_rewrite.cpp @@ -724,17 +724,36 @@ void yf::HttpRewrite::Content::configure( ("Empty rule in '" + values[3] + "' in http_rewrite filter"); } - size_t i; - for (i = 0; i < rulenames.size(); i++) + else if (rulenames.size() == 1) { std::map::const_iterator it = - rules.find(rulenames[i]); + rules.find(rulenames[0]); if (it == rules.end()) throw mp::filter::FilterException - ("Reference to non-existing rule '" + rulenames[i] + + ("Reference to non-existing rule '" + rulenames[0] + "' in http_rewrite filter"); - if (i == 0) - w.rule = it->second; + w.rule = it->second; + + } + else + { + RulePtr rule(new Rule); + size_t i; + for (i = 0; i < rulenames.size(); i++) + { + std::map::const_iterator it = + rules.find(rulenames[i]); + if (it == rules.end()) + throw mp::filter::FilterException + ("Reference to non-existing rule '" + rulenames[i] + + "' in http_rewrite filter"); + RulePtr subRule = it->second; + std::list::iterator rit = + subRule->replace_list.begin(); + for (; rit != subRule->replace_list.end(); rit++) + rule->replace_list.push_back(*rit); + } + w.rule = rule; } w.reqline = values[4] == "1"; w.type = values[5]; diff --git a/src/test_filter_rewrite.cpp b/src/test_filter_rewrite.cpp index 68acc0f..360246a 100644 --- a/src/test_filter_rewrite.cpp +++ b/src/test_filter_rewrite.cpp @@ -68,9 +68,11 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) " \n" " \n" " \n" + " \n" + " \n" + " \n" " \n" " \n" - " \n" " \n" @@ -82,7 +84,7 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) " \n" " \n" " \n" - " \n" + " \n" " \n" " \n" " \n"