diff --git a/tornado/test/wsgi_test.py b/tornado/test/wsgi_test.py index edca7c5103..c7894cca06 100644 --- a/tornado/test/wsgi_test.py +++ b/tornado/test/wsgi_test.py @@ -25,17 +25,27 @@ class HelloHandler(RequestHandler): def get(self): self.write("Hello world!") + class PathQuotingHandler(RequestHandler): + def get(self, path): + self.write(path) + # It would be better to run the wsgiref server implementation in # another thread instead of using our own WSGIContainer, but this # fits better in our async testing framework and the wsgiref # validator should keep us honest return WSGIContainer(validator(WSGIApplication([ - ("/", HelloHandler)]))) + ("/", HelloHandler), + ("/path/(.*)", PathQuotingHandler), + ]))) def test_simple(self): response = self.fetch("/") self.assertEqual(response.body, b("Hello world!")) + def test_path_quoting(self): + response = self.fetch("/path/foo%20bar%C3%A9") + self.assertEqual(response.body, u"foo bar\u00e9".encode("utf-8")) + # This is kind of hacky, but run some of the HTTPServer tests through # WSGIContainer and WSGIApplication to make sure everything survives # repeated disassembly and reassembly. diff --git a/tornado/wsgi.py b/tornado/wsgi.py index ab87a4ceaa..8b6177f7fd 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -235,7 +235,7 @@ def environ(request): environ = { "REQUEST_METHOD": request.method, "SCRIPT_NAME": "", - "PATH_INFO": request.path, + "PATH_INFO": urllib.unquote(request.path), "QUERY_STRING": request.query, "REMOTE_ADDR": request.remote_ip, "SERVER_NAME": host,