Remove special router logic for trailing slash
The trailing slash logic in the router has been long since deprecated in
leiu of adding two routes internally, so this "special case" is no
longer needed or used, as can be seen from the variable being read, but
never set anywhere.
Tested:
curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/SessionService/Sessions/
Succeeds
Ran redfish service validator. No new failures.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I9a6744d311aacaed1cc3eb3a98d55006c5b4246d
diff --git a/http/routing.hpp b/http/routing.hpp
index 250cd33..5b819c5 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -661,8 +661,6 @@
handler;
};
-const int ruleSpecialRedirectSlash = 1;
-
class Trie
{
public:
@@ -1172,30 +1170,6 @@
throw std::runtime_error("Trie internal structure corrupted!");
}
- if (ruleIndex == ruleSpecialRedirectSlash)
- {
- BMCWEB_LOG_INFO << "Redirecting to a url with trailing slash: "
- << req.url;
- res.result(boost::beast::http::status::moved_permanently);
-
- // TODO absolute url building
- if (req.getHeaderValue("Host").empty())
- {
- res.addHeader("Location", std::string(req.url) + "/");
- }
- else
- {
- res.addHeader(
- "Location",
- req.isSecure
- ? "https://"
- : "http://" + std::string(req.getHeaderValue("Host")) +
- std::string(req.url) + "/");
- }
- res.end();
- return;
- }
-
if ((rules[ruleIndex]->getMethods() &
(1U << static_cast<size_t>(req.method()))) == 0)
{
@@ -1276,29 +1250,6 @@
throw std::runtime_error("Trie internal structure corrupted!");
}
- if (ruleIndex == ruleSpecialRedirectSlash)
- {
- BMCWEB_LOG_INFO << "Redirecting to a url with trailing slash: "
- << req.url;
- asyncResp->res.result(
- boost::beast::http::status::moved_permanently);
-
- // TODO absolute url building
- if (req.getHeaderValue("Host").empty())
- {
- asyncResp->res.addHeader("Location",
- std::string(req.url) + "/");
- }
- else
- {
- asyncResp->res.addHeader(
- "Location", (req.isSecure ? "https://" : "http://") +
- std::string(req.getHeaderValue("Host")) +
- std::string(req.url) + "/");
- }
- return;
- }
-
if ((rules[ruleIndex]->getMethods() &
(1U << static_cast<uint32_t>(req.method()))) == 0)
{
@@ -1464,9 +1415,9 @@
{
std::vector<BaseRule*> rules;
Trie trie;
- // rule index 0, 1 has special meaning; preallocate it to avoid
+ // rule index 0 has special meaning; preallocate it to avoid
// duplication.
- PerMethod() : rules(2)
+ PerMethod() : rules(1)
{}
};