From 6bc88607a5726bcf482ceb23d0cf5e7dd9db8341 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 25 Jun 2013 15:21:15 +0200 Subject: [PATCH] Refactor a bit --- src/filter_http_rewrite.cpp | 25 ++++++++++++++++--------- src/filter_http_rewrite.hpp | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/filter_http_rewrite.cpp b/src/filter_http_rewrite.cpp index 3adc7db..098c349 100644 --- a/src/filter_http_rewrite.cpp +++ b/src/filter_http_rewrite.cpp @@ -64,7 +64,7 @@ namespace metaproxy_1 { RulePtr rule; }; - class HttpRewrite::Phase : public HTMLParserEvent { + class HttpRewrite::Phase { public: std::list 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 & 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::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) { } diff --git a/src/filter_http_rewrite.hpp b/src/filter_http_rewrite.hpp index 970f353..e2ed58c 100644 --- a/src/filter_http_rewrite.hpp +++ b/src/filter_http_rewrite.hpp @@ -32,6 +32,7 @@ namespace metaproxy_1 { class Replace; class Rule; class Within; + class Event; typedef boost::shared_ptr RulePtr; boost::scoped_ptr req_phase; boost::scoped_ptr res_phase; -- 1.7.10.4