Quick-fix for HttpRouter priority flaw

This commit is contained in:
Alex Hultman
2020-01-19 19:43:26 +01:00
parent 4e0db32165
commit 61b69169c7
2 changed files with 73 additions and 8 deletions
+60 -2
View File
@@ -119,7 +119,7 @@ void testUpgrade() {
}, r.HIGH_PRIORITY);
assert(r.route("get", "/something"));
assert(result == "GS");
assert(result == "WWGS");
result.clear();
assert(r.route("get", "/") == false);
@@ -150,7 +150,7 @@ void testBugReports() {
}, r.MEDIUM_PRIORITY);
r.route("get", "/ok");
assert(result == "GSWWGW");
assert(result == "WWGSGW");
}
{
@@ -172,6 +172,64 @@ void testBugReports() {
r.route("get", "/");
assert(result == "WSGS");
}
{
uWS::HttpRouter<int> r;
std::string result;
/* WS on /* */
r.add({"get"}, "/*", [&result](auto *) {
result += "WW";
return false;
}, r.HIGH_PRIORITY);
/* GET on /static */
r.add({"get"}, "/static", [&result](auto *) {
result += "GSL";
return false;
}, r.MEDIUM_PRIORITY);
/* ANY on /* */
r.add(r.methods, "/*", [&result](auto *) {
result += "AW";
return false;
}, r.LOW_PRIORITY);
r.route("get", "/static");
assert(result == "WWGSLAW");
}
{
uWS::HttpRouter<int> r;
std::string result;
/* WS on /* */
r.add({"get"}, "/*", [&result](auto *) {
result += "WW";
return false;
}, r.HIGH_PRIORITY);
/* GET on / */
r.add({"get"}, "/", [&result](auto *) {
result += "GSS";
return false;
}, r.MEDIUM_PRIORITY);
/* GET on /static */
r.add({"get"}, "/static", [&result](auto *) {
result += "GSL";
return false;
}, r.MEDIUM_PRIORITY);
/* ANY on /* */
r.add(r.methods, "/*", [&result](auto *) {
result += "AW";
return false;
}, r.LOW_PRIORITY);
r.route("get", "/static");
assert(result == "WWGSLAW");
}
}
void testParameters() {