Refactor a bit
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 25 Jun 2013 13:21:15 +0000 (15:21 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 25 Jun 2013 13:21:15 +0000 (15:21 +0200)
src/filter_http_rewrite.cpp
src/filter_http_rewrite.hpp

index 3adc7db..098c349 100644 (file)
@@ -64,7 +64,7 @@ namespace metaproxy_1 {
             RulePtr rule;
         };
 
-        class HttpRewrite::Phase : public HTMLParserEvent {
+        class HttpRewrite::Phase {
         public:
             std::list<Within> within_list;
             void rewrite_reqline(mp::odr & o, Z_HTTP_Request *hreq,
@@ -74,6 +74,9 @@ namespace metaproxy_1 {
             void rewrite_body(mp::odr & o,
                 char **content_buf, int *content_len,
                 std::map<std::string, std::string> & vars) const;
+        };
+        class HttpRewrite::Event : public HTMLParserEvent {
+        public:
             void openTagStart(const char *name);
             void anyTagEnd(const char *name);
             void attribute(const char *tagName, 
@@ -204,7 +207,11 @@ void yf::HttpRewrite::Phase::rewrite_body(mp::odr & o,
 {
     if (*content_buf)
     {
+        HTMLParser parser;
+        Event ev;
+        std::string buf(*content_buf, *content_len);
 
+        parser.parse(ev, buf.c_str());
         std::list<Within>::const_iterator it = within_list.begin();
         if (it != within_list.end())
         {
@@ -222,27 +229,27 @@ void yf::HttpRewrite::Phase::rewrite_body(mp::odr & o,
 }
 
 
-void yf::HttpRewrite::Phase::openTagStart(const char *name)
+void yf::HttpRewrite::Event::openTagStart(const char *name)
 {
 }
 
-void yf::HttpRewrite::Phase::anyTagEnd(const char *name)
+void yf::HttpRewrite::Event::anyTagEnd(const char *name)
 {
 }
 
-void yf::HttpRewrite::Phase::attribute(const char *tagName,
-                                       const char *name,
-                                       const char *value,
-                                       int val_len)
+void yf::HttpRewrite::Event::attribute(const char *tagName,
+                                         const char *name,
+                                         const char *value,
+                                         int val_len)
 {
 }
 
 
-void yf::HttpRewrite::Phase::closeTag(const char *name)
+void yf::HttpRewrite::Event::closeTag(const char *name)
 {
 }
 
-void yf::HttpRewrite::Phase::text(const char *value, int len)
+void yf::HttpRewrite::Event::text(const char *value, int len)
 {
 }
 
index 970f353..e2ed58c 100644 (file)
@@ -32,6 +32,7 @@ namespace metaproxy_1 {
             class Replace;
             class Rule;
             class Within;
+            class Event;
             typedef boost::shared_ptr<Rule> RulePtr;
             boost::scoped_ptr<Phase> req_phase;
             boost::scoped_ptr<Phase> res_phase;