From 191cdaf893b48dfc7610b4dbafda7702aa620f1e Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Thu, 2 May 2013 18:30:30 +0200 Subject: [PATCH] Only remember match if not empty --- src/test_filter_rewrite.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/test_filter_rewrite.cpp b/src/test_filter_rewrite.cpp index 4f6f0f4..f2962e1 100644 --- a/src/test_filter_rewrite.cpp +++ b/src/test_filter_rewrite.cpp @@ -85,8 +85,9 @@ public: gdu = package.response().get(); if (gdu && gdu->which == Z_GDU_HTTP_Response) { - std::cout << "<< Respose headers" << std::endl; Z_HTTP_Response *hr = gdu->u.HTTP_Response; + std::cout << "Response " << hr->code; + std::cout << "<< Respose headers" << std::endl; mp::odr o; //iterate headers for (Z_HTTP_Header *header = hr->headers; @@ -130,7 +131,8 @@ public: if (it != groups_by_num.end()) { //it is std::string name = it->second; - vars[name] = what[i]; + if (!what[i].str().empty()) + vars[name] = what[i]; } } @@ -235,7 +237,9 @@ public: std::map::const_iterator it = vars.find(name); if (it != vars.end()) + { out += it->second; + } } else { @@ -297,8 +301,9 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_2 ) FilterHeaderRewrite fhr; fhr.configure( - "(?:http\\:\\/\\/s?)?(?[A-Za-z.]+):(?\\d+)", - "http://${host}:${port}/somepath", + "((?http\\:\\/\\/s?)(?[^\\/?#]+)\\/(?[^\\/]+)" + "(?.+))|(proxyhost)", + "${proto}${target}${whatever}", //rewrite connection close "close", "open for ${host}"); @@ -313,7 +318,7 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_2 ) mp::odr odr; Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr, - "http://localhost:80/~jakub/targetsite.php", 0, 1); + "http://proxyhost/proxypath/localhost:80/~jakub/targetsite.php", 0, 1); pack.request() = gdu_req; -- 1.7.10.4