From 517d835e05e8f9169119ee9108692c2337d7b8bd Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Fri, 3 May 2013 15:01:55 +0200 Subject: [PATCH] Reconstruct headers before matching --- src/test_filter_rewrite.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/test_filter_rewrite.cpp b/src/test_filter_rewrite.cpp index 67755dd..0a62c0c 100644 --- a/src/test_filter_rewrite.cpp +++ b/src/test_filter_rewrite.cpp @@ -77,12 +77,25 @@ public: header != 0; header = header->next) { + std::string sheader(header->name); + sheader += ": "; + sheader += header->value; std::cout << header->name << ": " << header->value << std::endl; std::string out = test_patterns(vars, - std::string(header->value), + sheader, req_uri_pats, req_groups_bynum); - if (!out.empty()) - header->value = odr_strdup(o, out.c_str()); + if (!out.empty()) + { + size_t pos = out.find(": "); + if (pos == std::string::npos) + { + std::cout << "Header malformed during rewrite, ignoring"; + continue; + } + header->name = odr_strdup(o, out.substr(0, pos).c_str()); + header->value = odr_strdup(o, out.substr(pos+2, + std::string::npos).c_str()); + } } package.request() = gdu; } @@ -335,12 +348,12 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_2 ) spair_vec vec_req; vec_req.push_back(std::make_pair( "(?http\\:\\/\\/s?)(?[^\\/?#]+)\\/(?[^\\/]+)" - "\\/(?.+)", - "${proto}${target}" + "\\/(?[^\\/]+)(?.*)", + "${proto}${host}${path}" )); vec_req.push_back(std::make_pair( - "proxyhost", - "localhost" + "(?:Host\\: )(.*)", + "Host: localhost" )); spair_vec vec_res; -- 1.7.10.4