projects
/
metaproxy-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7ef92a3
)
Rewrite body too
author
Jakub Skoczen
<jakub@indexdata.dk>
Mon, 6 May 2013 10:45:46 +0000
(12:45 +0200)
committer
Jakub Skoczen
<jakub@indexdata.dk>
Mon, 6 May 2013 10:45:46 +0000
(12:45 +0200)
src/test_filter_rewrite.cpp
patch
|
blob
|
history
diff --git
a/src/test_filter_rewrite.cpp
b/src/test_filter_rewrite.cpp
index
6864033
..
eee048d
100644
(file)
--- a/
src/test_filter_rewrite.cpp
+++ b/
src/test_filter_rewrite.cpp
@@
-55,17
+55,19
@@
public:
std::cout << ">> Request headers" << std::endl;
rewrite_reqline(o, hreq, vars);
rewrite_headers(o, hreq->headers, vars);
std::cout << ">> Request headers" << std::endl;
rewrite_reqline(o, hreq, vars);
rewrite_headers(o, hreq->headers, vars);
+ rewrite_body(o, &hreq->content_buf, &hreq->content_len, vars);
package.request() = gdu;
}
package.move();
gdu = package.response().get();
if (gdu && gdu->which == Z_GDU_HTTP_Response)
{
package.request() = gdu;
}
package.move();
gdu = package.response().get();
if (gdu && gdu->which == Z_GDU_HTTP_Response)
{
- Z_HTTP_Response *hr = gdu->u.HTTP_Response;
- std::cout << "Response " << hr->code;
+ Z_HTTP_Response *hres = gdu->u.HTTP_Response;
+ std::cout << "Response " << hres->code;
std::cout << "<< Respose headers" << std::endl;
mp::odr o;
std::cout << "<< Respose headers" << std::endl;
mp::odr o;
- rewrite_headers(o, hr->headers, vars);
+ rewrite_headers(o, hres->headers, vars);
+ rewrite_body(o, &hres->content_buf, &hres->content_len, vars);
package.response() = gdu;
}
}
package.response() = gdu;
}
}
@@
-124,6
+126,23
@@
public:
}
}
}
}
+ void rewrite_body (mp::odr & o, char **content_buf, int *content_len,
+ std::map<std::string, std::string> & vars) const
+ {
+ if (*content_buf)
+ {
+ std::string body(*content_buf);
+ std::string nbody =
+ test_patterns(vars, body, req_uri_pats, req_groups_bynum);
+ if (!nbody.empty())
+ {
+ *content_buf = odr_strdup(o, nbody.c_str());
+ *content_len = nbody.size();
+ }
+ }
+ }
+
+
void configure(const xmlNode* ptr, bool test_only, const char *path) {};
/**
void configure(const xmlNode* ptr, bool test_only, const char *path) {};
/**