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:
6ca510d
)
Reconstruct headers before matching
author
Jakub Skoczen
<jakub@indexdata.dk>
Fri, 3 May 2013 13:01:55 +0000
(15:01 +0200)
committer
Jakub Skoczen
<jakub@indexdata.dk>
Fri, 3 May 2013 13:01:55 +0000
(15:01 +0200)
src/test_filter_rewrite.cpp
patch
|
blob
|
history
diff --git
a/src/test_filter_rewrite.cpp
b/src/test_filter_rewrite.cpp
index
67755dd
..
0a62c0c
100644
(file)
--- a/
src/test_filter_rewrite.cpp
+++ b/
src/test_filter_rewrite.cpp
@@
-77,12
+77,25
@@
public:
header != 0;
header = header->next)
{
header != 0;
header = header->next)
{
+ std::string sheader(header->name);
+ sheader += ": ";
+ sheader += header->value;
std::cout << header->name << ": " << header->value << std::endl;
std::string out = test_patterns(vars,
std::cout << header->name << ": " << header->value << std::endl;
std::string out = test_patterns(vars,
- std::string(header->value),
+ sheader,
req_uri_pats, req_groups_bynum);
req_uri_pats, req_groups_bynum);
- if (!out.empty())
- header->value = odr_strdup(o, out.c_str());
+ if (!out.empty())
+ {
+ size_t pos = out.find(": ");
+ if (pos == std::string::npos)
+ {
+ std::cout << "Header malformed during rewrite, ignoring";
+ continue;
+ }
+ header->name = odr_strdup(o, out.substr(0, pos).c_str());
+ header->value = odr_strdup(o, out.substr(pos+2,
+ std::string::npos).c_str());
+ }
}
package.request() = gdu;
}
}
package.request() = gdu;
}
@@
-335,12
+348,12
@@
BOOST_AUTO_TEST_CASE( test_filter_rewrite_2 )
spair_vec vec_req;
vec_req.push_back(std::make_pair(
"(?<proto>http\\:\\/\\/s?)(?<pxhost>[^\\/?#]+)\\/(?<pxpath>[^\\/]+)"
spair_vec vec_req;
vec_req.push_back(std::make_pair(
"(?<proto>http\\:\\/\\/s?)(?<pxhost>[^\\/?#]+)\\/(?<pxpath>[^\\/]+)"
- "\\/(?<target>.+)",
- "${proto}${target}"
+ "\\/(?<host>[^\\/]+)(?<path>.*)",
+ "${proto}${host}${path}"
));
vec_req.push_back(std::make_pair(
));
vec_req.push_back(std::make_pair(
- "proxyhost",
- "localhost"
+ "(?:Host\\: )(.*)",
+ "Host: localhost"
));
spair_vec vec_res;
));
spair_vec vec_res;