- void rewrite_req_header(Z_HTTP_Header *header) const
- {
- //exec regex against value
- boost::regex e(req_uri_pat, boost::regex::perl);
- boost::smatch what;
- std::string hvalue(header->value);
- if(boost::regex_match(hvalue, what, e, boost::match_extra))
- {
- unsigned i, j;
- std::cout << "** Match found **\n Sub-Expressions:\n";
- for(i = 0; i < what.size(); ++i)
- std::cout << " $" << i << " = \"" << what[i] << "\"\n";
- std::cout << " Captures:\n";
- for(i = 0; i < what.size(); ++i)
- {
- std::cout << " $" << i << " = {";
- for(j = 0; j < what.captures(i).size(); ++j)
- {
- if(j)
- std::cout << ", ";
- else
- std::cout << " ";
- std::cout << "\"" << what.captures(i)[j] << "\"";
- }
- std::cout << " }\n";
- }
- }
- else
+ std::cout << xmlconf;
+
+ // reading and parsing XML conf
+ xmlDocPtr doc = xmlParseMemory(xmlconf.c_str(), xmlconf.size());
+ BOOST_CHECK(doc);
+ xmlNode *root_element = xmlDocGetRootElement(doc);
+ fhr.configure(root_element, true, "");
+ xmlFreeDoc(doc);
+
+ router.append(fhr);
+
+ // create an http request
+ mp::Package pack;
+
+ mp::odr odr;
+ Z_GDU *gdu_req = z_get_HTTP_Request_uri(odr,
+ "http://proxyhost/proxypath/targetsite/page1.html", 0, 1);
+
+ pack.request() = gdu_req;
+
+ //create the http response
+
+ const char *resp_buf =
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 441\r\n"
+ "Content-Type: text/html\r\n"
+ "Link: <http://targetsite/file.xml>; rel=absolute\r\n"
+ "Link: </dir/file.xml>; rel=relative\r\n"
+ "\r\n"
+ "<html><head><title>Hello proxy!</title>"
+ "<style>"
+ "body {"
+ " background-image:url('http://targetsite/images/bg.png');"
+ "}"
+ "</style>"
+ "</head>"
+ "<script>var jslink=\"http://targetsite/webservice.xml\";"
+ "var some=foo;"
+ "</script>"
+ "<body>"
+ "<p>Welcome to our website. It doesn't make it easy to get pro"
+ "xified"
+ "<a href=\"http://targetsite/page2.html\">"
+ " An absolute link</a>"
+ "<a target=_blank href=\"http://targetsite/page3.html\">"
+ " Another abs link</a>"
+ "<a href=\"/docs/page4.html\" />"
+ "<a href=\"cxcx\" />"
+ "<a href=\"cx \" />"
+ "</body></html>";
+
+ const char *resp_expected =
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 564\r\n"
+ "Content-Type: text/html\r\n"
+ "Link: <http://proxyhost/proxypath/targetsite/file.xml>; rel=absolute\r\n"
+ "Link: </dir/file.xml>; rel=relative\r\n"
+ "\r\n"
+ "<html><head><title>Hello proxy!</title>"
+ "<style>"
+ "body {"
+ " background-image:url('http://proxyhost/proxypath/targetsite/images/bg.png');"
+ "}"
+ "</style>"
+ "</head>"
+ "<script>var jslink=\"http://proxyhost/proxypath/targetsite/webservice.xml\";"
+ "var some=bar;"
+ "</script>"
+ "<body>"
+ "<p>Welcome to our website. It doesn't make it easy to get pro"
+ "xified"
+ "<a href=\"http://proxyhost/proxypath/targetsite/page2.html\">"
+ " An absolute link</a>"
+ "<a target=_blank href=\"http://proxyhost/proxypath/targetsite/page3.html\">"
+ " Another abs link</a>"
+ "<a href=\"/docs/page4.html\"/>"
+ "<a href=\"cycx\"/>"
+ "<a href=\"cy \"/>"
+ "</body></html>";
+
+ Z_GDU *gdu_res;
+ mp::odr dec(ODR_DECODE);
+ mp::odr enc(ODR_ENCODE);
+ odr_setbuf(dec, (char *) resp_buf, strlen(resp_buf), 0);
+ int r = z_GDU(dec, &gdu_res, 0, 0);
+
+ BOOST_CHECK(r);
+ if (r)