added warning that POST cannot be redirected when appending slash
This commit is contained in:
@@ -137,6 +137,8 @@ class Pecan(object):
|
||||
return node, remainder
|
||||
except NonCanonicalPath, e:
|
||||
if self.force_canonical and not _cfg(e.controller).get('accept_noncanonical', False):
|
||||
if request.method == 'POST':
|
||||
raise RuntimeError, "You have POSTed to a URL '%s' which requires a slash. Most browsers will not maintain POST data when redirected. Please update you code to POST to '%s/' or set force_canonical to False" % (request.routing_path, request.routing_path)
|
||||
raise exc.HTTPFound(add_slash=True)
|
||||
return e.controller, e.remainder
|
||||
|
||||
|
||||
@@ -693,6 +693,13 @@ class TestEngines(object):
|
||||
r = app.get('/sub', status=302)
|
||||
assert r.status_int == 302
|
||||
|
||||
try:
|
||||
r = app.post('/sub', dict(foo=1))
|
||||
raise Exception, "Post should fail"
|
||||
except Exception, e:
|
||||
raise e
|
||||
assert isinstance(e, RuntimeError)
|
||||
|
||||
r = app.get('/arg/index/foo')
|
||||
assert r.status_int == 200
|
||||
assert r.body == 'foo'
|
||||
@@ -714,6 +721,10 @@ class TestEngines(object):
|
||||
assert r.status_int == 200
|
||||
assert 'subindex' in r.body
|
||||
|
||||
r = app.post('/sub', dict(foo=1))
|
||||
assert r.status_int == 200
|
||||
assert 'subindex' in r.body
|
||||
|
||||
r = app.get('/sub/')
|
||||
assert r.status_int == 200
|
||||
assert 'subindex' in r.body
|
||||
|
||||
Reference in New Issue
Block a user