From 88c76a4d37d2b84aabe96e2e2f2bac8b34fdb28e Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Tue, 21 Feb 2017 00:02:02 -0500 Subject: Allow clients to call HEAD The HEAD method allows clients to get page response headers without actually downloading the content. Change-Id: Id69db83a74015df3a9f84d36f91a4a12e11ea7b6 Signed-off-by: Brad Bishop --- module/obmc/wsgi/apps/rest_dbus.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py index 95b9cb0..aa08bfa 100644 --- a/module/obmc/wsgi/apps/rest_dbus.py +++ b/module/obmc/wsgi/apps/rest_dbus.py @@ -74,18 +74,27 @@ class RouteHandler(object): self._rules = rules self.intf_match = obmc.utils.misc.org_dot_openbmc_match + if 'GET' in self._verbs: + self._verbs = list(set(self._verbs + ['HEAD'])) + def _setup(self, **kw): request.route_data = {} if request.method in self._verbs: return self.setup(**kw) - else: - self.find(**kw) - raise HTTPError( - 405, "Method not allowed.", Allow=','.join(self._verbs)) + + # Return 404 if path not found. + self.find(**kw) + + # Return 405. + raise HTTPError( + 405, "Method not allowed.", Allow=','.join(self._verbs)) def __call__(self, **kw): return getattr(self, 'do_' + request.method.lower())(**kw) + def do_head(self, **kw): + return self.do_get(**kw) + def install(self): self.app.route( self._rules, callback=self, -- cgit v1.2.1