diff --git a/gunicorn/http/request.py b/gunicorn/http/request.py index aeca3c0a..0a4edc24 100644 --- a/gunicorn/http/request.py +++ b/gunicorn/http/request.py @@ -106,7 +106,10 @@ class Request(object): script_name = self.parser.headers_dict.get("SCRIPT_NAME", os.environ.get("SCRIPT_NAME", "")) - + path_info = self.parser.path + if script_name: + path_info = path_info.split(script_name)[-1] + environ = { "wsgi.url_scheme": 'http', "wsgi.input": wsgi_input, @@ -118,7 +121,7 @@ class Request(object): "SCRIPT_NAME": script_name, "SERVER_SOFTWARE": self.SERVER_VERSION, "REQUEST_METHOD": self.parser.method, - "PATH_INFO": unquote(self.parser.path), + "PATH_INFO": unquote(path_info), "QUERY_STRING": self.parser.query_string, "RAW_URI": self.parser.raw_path, "CONTENT_TYPE": self.parser.headers_dict.get('Content-Type', ''), diff --git a/tests/002-test-request.py b/tests/002-test-request.py index 600ce674..b14e1c45 100644 --- a/tests/002-test-request.py +++ b/tests/002-test-request.py @@ -3,7 +3,7 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. - +import os import t from gunicorn.http import tee @@ -138,3 +138,14 @@ def test_017(req): t.eq(e['PATH_INFO'], "/stuff/here") t.eq(e["HTTP_IF_MATCH"], "bazinga!, large-sound") t.eq(e["wsgi.input"].read(), "") + +@t.http_request("017.http") +def test_018(req): + os.environ['SCRIPT_NAME'] = "/stuff" + e = req.read() + t.eq(e['REQUEST_METHOD'], 'GET') + t.eq(e['SCRIPT_NAME'], "/stuff") + t.eq(e['PATH_INFO'], "/here") + t.eq(e["wsgi.input"].read(), "") + +