Merge "Fix bug with swob.Request.path_info_pop"
This commit is contained in:
commit
02429858de
@ -758,10 +758,12 @@ class Request(object):
|
|||||||
the path segment.
|
the path segment.
|
||||||
"""
|
"""
|
||||||
path_info = self.path_info
|
path_info = self.path_info
|
||||||
|
if not path_info or path_info[0] != '/':
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
slash_loc = path_info.index('/', 1)
|
slash_loc = path_info.index('/', 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
slash_loc = len(path_info)
|
||||||
self.script_name += path_info[:slash_loc]
|
self.script_name += path_info[:slash_loc]
|
||||||
self.path_info = path_info[slash_loc:]
|
self.path_info = path_info[slash_loc:]
|
||||||
return path_info[1:slash_loc]
|
return path_info[1:slash_loc]
|
||||||
|
@ -300,6 +300,18 @@ class TestRequest(unittest.TestCase):
|
|||||||
req = swift.common.swob.Request.blank('blahblah')
|
req = swift.common.swob.Request.blank('blahblah')
|
||||||
self.assertEquals(req.path_info_pop(), None)
|
self.assertEquals(req.path_info_pop(), None)
|
||||||
|
|
||||||
|
def test_path_info_pop_last(self):
|
||||||
|
req = swift.common.swob.Request.blank('/last')
|
||||||
|
self.assertEquals(req.path_info_pop(), 'last')
|
||||||
|
self.assertEquals(req.path_info, '')
|
||||||
|
self.assertEquals(req.script_name, '/last')
|
||||||
|
|
||||||
|
def test_path_info_pop_none(self):
|
||||||
|
req = swift.common.swob.Request.blank('/')
|
||||||
|
self.assertEquals(req.path_info_pop(), '')
|
||||||
|
self.assertEquals(req.path_info, '')
|
||||||
|
self.assertEquals(req.script_name, '/')
|
||||||
|
|
||||||
def test_copy_get(self):
|
def test_copy_get(self):
|
||||||
req = swift.common.swob.Request.blank(
|
req = swift.common.swob.Request.blank(
|
||||||
'/hi/there', environ={'REQUEST_METHOD': 'POST'})
|
'/hi/there', environ={'REQUEST_METHOD': 'POST'})
|
||||||
|
Loading…
Reference in New Issue
Block a user