diff options
author | Ed Tanous <edtanous@google.com> | 2022-03-14 19:27:38 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-03-17 04:52:52 +0300 |
commit | 313a3c286ab95f7117b4b054b20ef79eb12b9d64 (patch) | |
tree | a1d875f67fc573422f777bbe2c7ae9d8d110f687 | |
parent | 9e710e7f988dee6d794c8f0a13e83b9b47a764db (diff) | |
download | bmcweb-313a3c286ab95f7117b4b054b20ef79eb12b9d64.tar.xz |
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
-rw-r--r-- | http/routing.hpp | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/http/routing.hpp b/http/routing.hpp index 250cd3354e..5b819c582c 100644 --- a/http/routing.hpp +++ b/http/routing.hpp @@ -661,8 +661,6 @@ class TaggedRule : handler; }; -const int ruleSpecialRedirectSlash = 1; - class Trie { public: @@ -1172,30 +1170,6 @@ class Router 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 @@ class Router 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 @@ class Router { 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) {} }; |