diff options
author | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2013-01-15 16:52:22 +0100 |
---|---|---|
committer | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2013-01-15 16:52:22 +0100 |
commit | fd61aac7c719a875ecdcc2e43d7dcf561bc28eca (patch) | |
tree | d7820295f6b2f0d6008bcb4231706305c573bfa9 /mediagoblin/app.py | |
parent | 65969d3fb799765854ac5f57f85842c6ab523b21 (diff) | |
download | mediagoblin-fd61aac7c719a875ecdcc2e43d7dcf561bc28eca.tar.lz mediagoblin-fd61aac7c719a875ecdcc2e43d7dcf561bc28eca.tar.xz mediagoblin-fd61aac7c719a875ecdcc2e43d7dcf561bc28eca.zip |
Unbreak 301 responses
The move to werkzeug routing went pretty smooth, but one thing was
broken by accident: URLs without final slash result in a 301
werkzeug.routing.RequestRedirect response. We displayed it as a generic
error page rather than actually sending the redirect. Do that. One thing
it does though is to skip all meddlewares, which should be OK for a 301
response, but might need rework if we decide otherwise. With this, 301
responses with lacking final slash are unbroken again.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Diffstat (limited to 'mediagoblin/app.py')
-rw-r--r-- | mediagoblin/app.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mediagoblin/app.py b/mediagoblin/app.py index c1636693..10fbf4a3 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -22,6 +22,7 @@ from mediagoblin.tools.routing import endpoint_to_controller from werkzeug.wrappers import Request from werkzeug.exceptions import HTTPException, NotFound +from werkzeug.routing import RequestRedirect from mediagoblin import meddleware, __version__ from mediagoblin.tools import common, translate, template @@ -186,6 +187,9 @@ class MediaGoblinApp(object): try: found_rule, url_values = map_adapter.match(return_rule=True) request.matchdict = url_values + except RequestRedirect as response: + # Deal with 301 responses eg due to missing final slash + return response(environ, start_response) except HTTPException as exc: # Stop and render exception return render_http_exception( |