mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
the way to get full path is "SCHEME://SERVER_NAME:SERVER_PORT" +
SCRIPT_NAME + PATH_INFO
This commit is contained in:
parent
7ca593ace7
commit
c557ecc93b
@ -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', ''),
|
||||
|
||||
@ -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(), "")
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user