summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Saddi <allan@saddi.com>2008-07-22 09:53:30 -0700
committerAllan Saddi <allan@saddi.com>2008-07-22 09:53:30 -0700
commit206878f9439d93e0ae08162df28b85bc9a54a369 (patch)
treea1101f4365387ef7409c18917bd709cb5e0f3500
parent80ef6eecad7b42dffdb38fa510d71ebe3a012581 (diff)
downloadflup-206878f9439d93e0ae08162df28b85bc9a54a369.tar.gz
Revise previous patch for compatibility with pre-2.5 Python.
-rw-r--r--flup/server/ajp_base.py8
-rw-r--r--flup/server/fcgi_base.py13
-rw-r--r--flup/server/scgi_base.py12
3 files changed, 23 insertions, 10 deletions
diff --git a/flup/server/ajp_base.py b/flup/server/ajp_base.py
index fd560c2..e4c38f2 100644
--- a/flup/server/ajp_base.py
+++ b/flup/server/ajp_base.py
@@ -924,9 +924,13 @@ class BaseAJPServer(object):
environ['PATH_INFO'] = value[len(scriptName):]
environ['SCRIPT_NAME'] = scriptName
+ reqUri = None
+ if environ.has_key('REQUEST_URI'):
+ reqUri = environ['REQUEST_URI'].split('?', 1)
+
if not environ.has_key('QUERY_STRING') or not environ['QUERY_STRING']:
- if environ.has_key['REQUEST_URI']:
- environ['QUERY_STRING'] = environ['REQUEST_URI'].partition('?')[2]
+ if reqUri is not None and len(reqUri) > 1:
+ environ['QUERY_STRING'] = reqUri[1]
else:
environ['QUERY_STRING'] = ''
diff --git a/flup/server/fcgi_base.py b/flup/server/fcgi_base.py
index 34c0fbd..e012c94 100644
--- a/flup/server/fcgi_base.py
+++ b/flup/server/fcgi_base.py
@@ -1136,14 +1136,19 @@ class BaseFCGIServer(object):
"""Ensure certain values are present, if required by WSGI."""
if not environ.has_key('SCRIPT_NAME'):
environ['SCRIPT_NAME'] = ''
+
+ reqUri = None
+ if environ.has_key('REQUEST_URI'):
+ reqUri = environ['REQUEST_URI'].split('?', 1)
+
if not environ.has_key('PATH_INFO') or not environ['PATH_INFO']:
- if environ.has_key('REQUEST_URI'):
- environ['PATH_INFO'] = environ['REQUEST_URI'].partition('?')[0]
+ if reqUri is not None:
+ environ['PATH_INFO'] = reqUri[0]
else:
environ['PATH_INFO'] = ''
if not environ.has_key('QUERY_STRING') or not environ['QUERY_STRING']:
- if environ.has_key('REQUEST_URI'):
- environ['QUERY_STRING'] = environ['REQUEST_URI'].partition('?')[2]
+ if reqUri is not None and len(reqUri) > 1:
+ environ['QUERY_STRING'] = reqUri[1]
else:
environ['QUERY_STRING'] = ''
diff --git a/flup/server/scgi_base.py b/flup/server/scgi_base.py
index 8c70ffb..0db511e 100644
--- a/flup/server/scgi_base.py
+++ b/flup/server/scgi_base.py
@@ -472,10 +472,14 @@ class BaseSCGIServer(object):
def _sanitizeEnv(self, environ):
"""Fill-in/deduce missing values in environ."""
+ reqUri = None
+ if environ.has_key('REQUEST_URI'):
+ reqUri = environ['REQUEST_URI'].split('?', 1)
+
# Ensure QUERY_STRING exists
if not environ.has_key('QUERY_STRING') or not environ['QUERY_STRING']:
- if environ.has_key('REQUEST_URI'):
- environ['QUERY_STRING'] = environ['REQUEST_URI'].partition('?')[2]
+ if reqUri is not None and len(reqUri) > 1:
+ environ['QUERY_STRING'] = reqUri[1]
else:
environ['QUERY_STRING'] = ''
@@ -499,8 +503,8 @@ class BaseSCGIServer(object):
if not environ.has_key('SCRIPT_NAME'):
environ['SCRIPT_INFO'] = ''
if not environ.has_key('PATH_INFO') or not environ['PATH_INFO']:
- if environ.has_key('REQUEST_URI'):
- environ['PATH_INFO'] = environ['REQUEST_URI'].partition('?')[0]
+ if reqUri is not None:
+ environ['PATH_INFO'] = reqUri[0]
else:
environ['PATH_INFO'] = ''
else: