diff --git a/eventlet/wsgi.py b/eventlet/wsgi.py index 3e04cb9..48df934 100644 --- a/eventlet/wsgi.py +++ b/eventlet/wsgi.py @@ -454,6 +454,7 @@ class HttpProtocol(BaseHTTPServer.BaseHTTPRequestHandler): env['SCRIPT_NAME'] = '' pq = self.path.split('?', 1) + env['RAW_PATH_INFO'] = pq[0] env['PATH_INFO'] = urllib.unquote(pq[0]) if len(pq) > 1: env['QUERY_STRING'] = pq[1] diff --git a/tests/wsgi_test.py b/tests/wsgi_test.py index ecdb688..1ed777c 100644 --- a/tests/wsgi_test.py +++ b/tests/wsgi_test.py @@ -622,8 +622,8 @@ class TestHttpd(_TestBase): for environ_var in ['wsgi.version', 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors', 'wsgi.multithread', 'wsgi.multiprocess', 'wsgi.run_once', 'REQUEST_METHOD', - 'SCRIPT_NAME', 'PATH_INFO', 'QUERY_STRING', 'CONTENT_TYPE', - 'CONTENT_LENGTH', 'SERVER_NAME', 'SERVER_PORT', + 'SCRIPT_NAME', 'RAW_PATH_INFO', 'PATH_INFO', 'QUERY_STRING', + 'CONTENT_TYPE', 'CONTENT_LENGTH', 'SERVER_NAME', 'SERVER_PORT', 'SERVER_PROTOCOL']: environ[environ_var] = None start_response('200 OK', [('Content-type', 'text/plain')]) @@ -975,6 +975,22 @@ class TestHttpd(_TestBase): self.assertEqual(headers['connection'], 'close') self.assert_('unicode' in body) + def test_path_info_decoding(self): + def wsgi_app(environ, start_response): + start_response("200 OK", []) + yield "decoded: %s" % environ['PATH_INFO'] + yield "raw: %s" % environ['RAW_PATH_INFO'] + self.site.application = wsgi_app + sock = eventlet.connect(('localhost', self.port)) + fd = sock.makefile('rw') + fd.write('GET /a*b@%40%233 HTTP/1.1\r\nHost: localhost\r\nConnection: '\ + 'close\r\n\r\n') + fd.flush() + response_line, headers, body = read_http(sock) + self.assert_(response_line.startswith('HTTP/1.1 200')) + self.assert_('decoded: /a*b@@#3' in body) + self.assert_('raw: /a*b@%40%233' in body) + def test_ipv6(self): try: sock = eventlet.listen(('::1', 0), family=socket.AF_INET6)