summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Saddi <allan@saddi.com>2005-04-16 09:45:05 +0000
committerAllan Saddi <allan@saddi.com>2005-04-16 09:45:05 +0000
commit6a3be0d55700f4efa4d9ddd108cd597f099b754e (patch)
treeb9a3376af65bb5dbc8d2f00dfc923196151d93b2
parent0b5c80e465a80686d2db6b32d80f9974cad81a95 (diff)
downloadflup-6a3be0d55700f4efa4d9ddd108cd597f099b754e.tar.gz
mod_scgi doesn't pass in PATH_INFO. Deduce from SCRIPT_NAME.
-rw-r--r--flup/server/scgi_base.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/flup/server/scgi_base.py b/flup/server/scgi_base.py
index 52648e9..e9e6268 100644
--- a/flup/server/scgi_base.py
+++ b/flup/server/scgi_base.py
@@ -267,11 +267,16 @@ class BaseSCGIServer(object):
# What Request class to use.
requestClass = Request
- def __init__(self, application, environ=None,
+ def __init__(self, application, scriptName='', environ=None,
multithreaded=True,
bindAddress=('localhost', 4000), allowedServers=None,
loggingLevel=logging.INFO):
"""
+ scriptName is the initial portion of the URL path that "belongs"
+ to your application. It is used to determine PATH_INFO (which doesn't
+ seem to be passed in). An empty scriptName means your application
+ is mounted at the root of your virtual host.
+
environ, which must be a dictionary, can contain any additional
environment variables you want to pass to your application.
@@ -292,6 +297,7 @@ class BaseSCGIServer(object):
environ = {}
self.application = application
+ self.scriptName = scriptName
self.environ = environ
self.multithreaded = multithreaded
self._bindAddress = bindAddress
@@ -345,6 +351,8 @@ class BaseSCGIServer(object):
else:
environ['wsgi.url_scheme'] = 'http'
+ self._sanitizeEnv(environ)
+
headers_set = []
headers_sent = []
result = None
@@ -425,6 +433,17 @@ class BaseSCGIServer(object):
if not self.multithreaded:
self._appLock.release()
+ def _sanitizeEnv(self, environ):
+ """Fill-in/deduce missing values in environ."""
+ # Namely SCRIPT_NAME/PATH_INFO
+ value = environ['SCRIPT_NAME']
+ scriptName = self.scriptName
+ if not value.startswith(scriptName):
+ self.logger.warning('scriptName does not match request URI')
+
+ environ['PATH_INFO'] = value[len(scriptName):]
+ environ['SCRIPT_NAME'] = scriptName
+
def error(self, request):
"""
Override to provide custom error handling. Ideally, however,