diff options
author | Allan Saddi <allan@saddi.com> | 2005-04-16 09:45:05 +0000 |
---|---|---|
committer | Allan Saddi <allan@saddi.com> | 2005-04-16 09:45:05 +0000 |
commit | 6a3be0d55700f4efa4d9ddd108cd597f099b754e (patch) | |
tree | b9a3376af65bb5dbc8d2f00dfc923196151d93b2 | |
parent | 0b5c80e465a80686d2db6b32d80f9974cad81a95 (diff) | |
download | flup-6a3be0d55700f4efa4d9ddd108cd597f099b754e.tar.gz |
mod_scgi doesn't pass in PATH_INFO. Deduce from SCRIPT_NAME.
-rw-r--r-- | flup/server/scgi_base.py | 21 |
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, |