def test_nonlatin_path(self, test_path):
# NOTE(kgriffs): When a request comes in, web servers decode
# the path. The decoded path may contain UTF-8 characters,
# but according to the WSGI spec, no strings can contain chars
# outside ISO-8859-1. Therefore, to reconcile the URI
# encoding standard that allows UTF-8 with the WSGI spec
# that does not, WSGI servers tunnel the string via
# ISO-8859-1. falcon.testing.create_environ() mimics this
# behavior, e.g.:
#
# tunnelled_path = path.encode('utf-8').decode('iso-8859-1')
#
# falcon.Request does the following to reverse the process:
#
# path = tunnelled_path.encode('iso-8859-1').decode('utf-8', 'replace')
#
req = Request(testing.create_environ(
host='com',
path=test_path,
headers=self.headers))
assert req.path == falcon.uri.decode(test_path)
评论列表
文章目录