From: Jakub Skoczen Date: Fri, 3 May 2013 13:01:55 +0000 (+0200) Subject: Reconstruct headers before matching X-Git-Tag: v1.3.59~57^2~30 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=517d835e05e8f9169119ee9108692c2337d7b8bd;p=metaproxy-moved-to-github.git Reconstruct headers before matching --- 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;