by default SCRIPT_name is an empy string. Value could be changed by

passing SCRIPT_NAME in environment (apache way) or as an HTTP header
(nginx way).
This commit is contained in:
benoitc 2010-02-18 11:15:28 +01:00
parent 375298e913
commit 7ca593ace7

View File

@ -3,11 +3,12 @@
# This file is part of gunicorn released under the MIT license. # This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information. # See the NOTICE for more information.
import logging
import os
import re import re
import StringIO import StringIO
import sys import sys
from urllib import unquote from urllib import unquote
import logging
from gunicorn import __version__ from gunicorn import __version__
from gunicorn.http.parser import Parser from gunicorn.http.parser import Parser
@ -102,7 +103,10 @@ class Request(object):
server_address = server_address.split(":") server_address = server_address.split(":")
if len(server_address) == 1: if len(server_address) == 1:
server_address.append('') server_address.append('')
script_name = self.parser.headers_dict.get("SCRIPT_NAME",
os.environ.get("SCRIPT_NAME", ""))
environ = { environ = {
"wsgi.url_scheme": 'http', "wsgi.url_scheme": 'http',
"wsgi.input": wsgi_input, "wsgi.input": wsgi_input,
@ -111,7 +115,7 @@ class Request(object):
"wsgi.multithread": False, "wsgi.multithread": False,
"wsgi.multiprocess": wsgi_multiprocess, "wsgi.multiprocess": wsgi_multiprocess,
"wsgi.run_once": False, "wsgi.run_once": False,
"SCRIPT_NAME": "", "SCRIPT_NAME": script_name,
"SERVER_SOFTWARE": self.SERVER_VERSION, "SERVER_SOFTWARE": self.SERVER_VERSION,
"REQUEST_METHOD": self.parser.method, "REQUEST_METHOD": self.parser.method,
"PATH_INFO": unquote(self.parser.path), "PATH_INFO": unquote(self.parser.path),