diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2014-06-26 10:11:44 -0400 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2014-06-26 10:22:08 -0400 |
commit | 63d9d3d8fdab69323010ace0f05ddfe10cae41f1 (patch) | |
tree | 822f164cd6ce7c6cba6f4f774dd251aa7824edaa /pecan/core.py | |
parent | 7d5b94e2f68aa254d4905e90572aa7dc5e04ab28 (diff) | |
download | pecan-63d9d3d8fdab69323010ace0f05ddfe10cae41f1.tar.gz |
For an HTTP 405 on generic methods, attempt to specify an Allow header.
Change-Id: I726d698fc014c21cc1e43a09a129384fa1f1235f
Diffstat (limited to 'pecan/core.py')
-rw-r--r-- | pecan/core.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pecan/core.py b/pecan/core.py index a43f3de..fae1502 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -631,6 +631,12 @@ class PecanBase(object): else: if not isinstance(e, exc.HTTPException): raise + + # if this is an HTTP 405, attempt to specify an Allow header + if isinstance(e, exc.HTTPMethodNotAllowed) and controller: + allowed_methods = _cfg(controller).get('allowed_methods', []) + if allowed_methods: + state.response.allow = sorted(allowed_methods) finally: # handle "after" hooks self.handle_hooks( |