summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Bicking <ianb@colorstudy.com>2010-08-20 13:40:28 -0500
committerIan Bicking <ianb@colorstudy.com>2010-08-20 13:40:28 -0500
commitf61854717bde6de3888c449975faf8faddaafad8 (patch)
treef6896e06e040e2b1692135365b4dd5a3cb0b91b9
parent90a1e81e6c4635517143a2e846baeac66eb7d4b7 (diff)
parent3c8acd42b9e89f3d4deacd5c3d5f6ff5cbf2acd5 (diff)
downloadpaste-f61854717bde6de3888c449975faf8faddaafad8.tar.gz
Automated merge with ssh://bitbucket.org/ianb/paste
-rw-r--r--paste/cgiapp.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/paste/cgiapp.py b/paste/cgiapp.py
index e1ede03..ac6fd73 100644
--- a/paste/cgiapp.py
+++ b/paste/cgiapp.py
@@ -6,6 +6,7 @@ Application that runs a CGI script.
"""
import os
import subprocess
+import urllib
try:
import select
except ImportError:
@@ -30,7 +31,7 @@ class CGIApplication(object):
a path, then ``$PATH`` will be used.
"""
- def __init__(self,
+ def __init__(self,
global_conf,
script,
path=None,
@@ -67,8 +68,8 @@ class CGIApplication(object):
def __call__(self, environ, start_response):
if 'REQUEST_URI' not in environ:
environ['REQUEST_URI'] = (
- environ.get('SCRIPT_NAME', '')
- + environ.get('PATH_INFO', ''))
+ urllib.quote(environ.get('SCRIPT_NAME', ''))
+ + urllib.quote(environ.get('PATH_INFO', '')))
if self.include_os_environ:
cgi_environ = os.environ.copy()
else:
@@ -125,7 +126,7 @@ class CGIWriter(object):
return
self.buffer += data
while '\n' in self.buffer:
- if '\r\n' in self.buffer:
+ if '\r\n' in self.buffer and self.buffer.find('\r\n') < self.buffer.find('\n'):
line1, self.buffer = self.buffer.split('\r\n', 1)
else:
line1, self.buffer = self.buffer.split('\n', 1)
@@ -146,6 +147,9 @@ class CGIWriter(object):
value = value.lstrip()
name = name.strip()
if name.lower() == 'status':
+ if ' ' not in value:
+ # WSGI requires this space, sometimes CGI scripts don't set it:
+ value = '%s General' % value
self.status = value
else:
self.headers.append((name, value))
@@ -252,12 +256,12 @@ def proc_communicate(proc, stdin=None, stdout=None, stderr=None):
except OSError, e:
if e.errno != 10:
raise
-
+
def make_cgi_application(global_conf, script, path=None, include_os_environ=None,
query_string=None):
"""
Paste Deploy interface for :class:`CGIApplication`
-
+
This object acts as a proxy to a CGI application. You pass in the
script path (``script``), an optional path to search for the
script (if the name isn't absolute) (``path``). If you don't give