summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2019-03-26 19:28:06 +0300
committerEd Tanous <ed.tanous@intel.com>2019-04-01 20:01:59 +0300
commit2634dcd96bf5c8171adad9da810fe1d54589703e (patch)
tree71edc83c3e98cfa25454c68577fcdce16aefa494
parentde5c9f3cf9637729d20318839f3c7d3ac51139fd (diff)
downloadbmcweb-2634dcd96bf5c8171adad9da810fe1d54589703e.tar.xz
bmcweb: return 405 when a method is not supported
bmcweb previously took the crow approach to return codes, returning 200 for many things that didn't provide a VERB definition in its declaration. This patch corrects bmcweb to return an appropriate error code when the verb isn't supported. Tested: Ran test case here: https://github.com/openbmc/bmcweb/issues/69 Observed 405 returned instead of 200. Change-Id: I4c0fb5e68d6163ba6ff30faf1af403015888d475 Signed-off-by: Ed Tanous <ed.tanous@intel.com>
-rw-r--r--crow/include/crow/routing.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/crow/include/crow/routing.h b/crow/include/crow/routing.h
index 7d7a1b6ea5..32d31efdbf 100644
--- a/crow/include/crow/routing.h
+++ b/crow/include/crow/routing.h
@@ -1170,6 +1170,18 @@ class Router
if (!ruleIndex)
{
+ // Check to see if this url exists at any verb
+ for (const PerMethod& p : perMethods)
+ {
+ const std::pair<unsigned, RoutingParams>& found =
+ p.trie.find(req.url);
+ if (found.first > 0)
+ {
+ res.result(boost::beast::http::status::method_not_allowed);
+ res.end();
+ return;
+ }
+ }
BMCWEB_LOG_DEBUG << "Cannot match rules " << req.url;
res.result(boost::beast::http::status::not_found);
res.end();