Fix warnings
[metaproxy-moved-to-github.git] / src / filter_http_rewrite.cpp
index e64fb36..bc65d16 100644 (file)
@@ -67,7 +67,7 @@ void yf::HttpRewrite::process(mp::Package & package) const
     if (gdu && gdu->which == Z_GDU_HTTP_Response)
     {
         Z_HTTP_Response *hres = gdu->u.HTTP_Response;
-        std::cout << "Response " << hres->code;
+        yaz_log(YLOG_DEBUG, "Response %d", hres->code);
         std::cout << "<< Respose headers" << std::endl;
         mp::odr o;
         rewrite_headers(o, hres->headers, vars);
@@ -157,7 +157,7 @@ const std::string yf::HttpRewrite::test_patterns(
         const std::vector<std::map<int, std::string> > & groups_bynum_vec)
     const
 {
-    for (int i = 0; i < uri_pats.size(); i++) 
+    for (unsigned i = 0; i < uri_pats.size(); i++) 
     {
         std::string out = search_replace(vars, txt, 
                 uri_pats[i].first, uri_pats[i].second,
@@ -214,7 +214,7 @@ void yf::HttpRewrite::parse_groups(
         const spair_vec & uri_pats,
         std::vector<std::map<int, std::string> > & groups_bynum_vec)
 {
-    for (int h = 0; h < uri_pats.size(); h++) 
+    for (unsigned h = 0; h < uri_pats.size(); h++) 
     {
         int gnum = 0;
         bool esc = false;
@@ -222,7 +222,7 @@ void yf::HttpRewrite::parse_groups(
         std::string str = uri_pats[h].first;
         //for each pair we have an indexing map
         std::map<int, std::string> groups_bynum;
-        for (int i = 0; i < str.size(); ++i)
+        for (unsigned i = 0; i < str.size(); ++i)
         {
             if (!esc && str[i] == '\\')
             {
@@ -281,7 +281,7 @@ std::string yf::HttpRewrite::sub_vars (const std::string & in,
 {
     std::string out;
     bool esc = false;
-    for (int i = 0; i < in.size(); ++i)
+    for (unsigned i = 0; i < in.size(); ++i)
     {
         if (!esc && in[i] == '\\')
         {
@@ -360,13 +360,14 @@ static void configure_rules(const xmlNode *ptr, yf::HttpRewrite::spair_vec & des
                          + std::string((const char *) attr->name)
                          + " in rewrite section of http_rewrite");
             }
+            std::cout << "Found rewrite rule from=" << from << " to " << to << std::endl;
             if (!from.empty())
                 dest.push_back(std::make_pair(from, to));
         }
         else
         {
             throw mp::filter::FilterException
-                ("Bad element "
+                ("Bad element o"
                  + std::string((const char *) ptr->name)
                  + " in http_rewrite1 filter");
         }
@@ -384,11 +385,12 @@ void yf::HttpRewrite::configure(const xmlNode * ptr, bool test_only,
             continue;
         else if (!strcmp((const char *) ptr->name, "request"))
         {
-            configure_rules(ptr->children, req_uri_pats);
+            std::cout << "Found request rule" << std::endl;
+            configure_rules(ptr, req_uri_pats);
         }
         else if (!strcmp((const char *) ptr->name, "response"))
         {
-            configure_rules(ptr->children, res_uri_pats);
+            configure_rules(ptr, res_uri_pats);
         }
         else
         {
@@ -398,6 +400,7 @@ void yf::HttpRewrite::configure(const xmlNode * ptr, bool test_only,
                  + " in http_rewrite1 filter");
         }
     }
+    configure(req_uri_pats, res_uri_pats);
 }
 
 static mp::filter::Base* filter_creator()