diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-02-21 00:02:02 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-02-26 12:11:37 -0500 |
commit | 88c76a4d37d2b84aabe96e2e2f2bac8b34fdb28e (patch) | |
tree | 187baf1ea36f1d407300a4fd82c8cda700db4dbf /module/obmc/wsgi/apps/rest_dbus.py | |
parent | 080a48ed0ad8f3b440fd66e2c9be64161eac22cc (diff) | |
download | phosphor-rest-server-88c76a4d37d2b84aabe96e2e2f2bac8b34fdb28e.tar.gz phosphor-rest-server-88c76a4d37d2b84aabe96e2e2f2bac8b34fdb28e.zip |
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 <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'module/obmc/wsgi/apps/rest_dbus.py')
-rw-r--r-- | module/obmc/wsgi/apps/rest_dbus.py | 17 |
1 files 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, |