[z3-checkins] r40792 - in z3/deliverance/DeliveranceVHoster/trunk: dvhoster tests
ianb at codespeak.net
ianb at codespeak.net
Mon Mar 19 21:02:09 CET 2007
Author: ianb
Date: Mon Mar 19 21:02:07 2007
New Revision: 40792
Modified:
z3/deliverance/DeliveranceVHoster/trunk/dvhoster/dispatcher.py
z3/deliverance/DeliveranceVHoster/trunk/tests/test_functional_api.py
Log:
Fix issue with trailing slash redirects (trailing /'s were eaten)
Modified: z3/deliverance/DeliveranceVHoster/trunk/dvhoster/dispatcher.py
==============================================================================
--- z3/deliverance/DeliveranceVHoster/trunk/dvhoster/dispatcher.py (original)
+++ z3/deliverance/DeliveranceVHoster/trunk/dvhoster/dispatcher.py Mon Mar 19 21:02:07 2007
@@ -19,7 +19,10 @@
if not urlpath:
urlpath = '/'
assert urlpath.startswith('/')
+ last_slash = urlpath.endswith('/')
urlpath = posixpath.normpath(posixpath.abspath(urlpath))
+ if last_slash:
+ urlpath += '/'
return urlpath
class DeliveranceDispatcher(object):
@@ -56,6 +59,7 @@
environ, with_query_string=False,
path_info='')
path_info = norm_path(environ.get('PATH_INFO', ''))
+ print 'path_info', repr(path_info), repr(environ['PATH_INFO'])
if path_info.startswith('/.deliverance'):
path_info_pop(environ)
subapp = ProviderApp(domain_info)
@@ -131,6 +135,7 @@
if not path.endswith('/'):
path += '/'
if path_info + '/' == path:
+ print 'redirect', [remote_uri_info, path, path_info]
exc = httpexceptions.HTTPMovedPermanently(
headers=[('location', construct_url(environ, path_info=path_info+'/'))])
return exc(environ, start_response)
Modified: z3/deliverance/DeliveranceVHoster/trunk/tests/test_functional_api.py
==============================================================================
--- z3/deliverance/DeliveranceVHoster/trunk/tests/test_functional_api.py (original)
+++ z3/deliverance/DeliveranceVHoster/trunk/tests/test_functional_api.py Mon Mar 19 21:02:07 2007
@@ -81,6 +81,14 @@
# It gets normalized, so it doesn't actually stay the same:
#assert app.get('/.deliverance/remote_uris').body == data
+ res = app.get('/bar', status=301)
+ assert res.header('location') == 'http://localhost/bar/'
+ ## @@: Right now there's a problem with StaticURLParser where it
+ ## does a bad redirect here...
+ #res = res.follow()
+ #print res
+ #assert res.status == 200
+
data = '''
[{"path": "/test1.html", "rewrite": "/test1"},
{"prefix": "/test2", "rewrite": "/test3", "comment": "rename"},
More information about the z3-checkins
mailing list