diff options
author | ianb <devnull@localhost> | 2005-08-18 21:55:21 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2005-08-18 21:55:21 +0000 |
commit | 836500cc2b65db7e04f844f7b7134d24cd1417ab (patch) | |
tree | c9e5ac4cf0c78cb29aca57a42b2d24f041b90034 /paste/cgiapp.py | |
parent | 944d01f49ebe3096da3c0ee810bea2b145338845 (diff) | |
download | paste-836500cc2b65db7e04f844f7b7134d24cd1417ab.tar.gz |
Fixed problem with scripts that don't output any headers, and chop query string off earlier
Diffstat (limited to 'paste/cgiapp.py')
-rw-r--r-- | paste/cgiapp.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/paste/cgiapp.py b/paste/cgiapp.py index c1f4c14..ff98452 100644 --- a/paste/cgiapp.py +++ b/paste/cgiapp.py @@ -28,6 +28,11 @@ class CGIApplication(object): if path is None: path = os.environ.get('PATH', '').split(':') self.path = path + if '?' in script: + assert query_string is None, ( + "You cannot have '?' in your script name (%r) and also " + "give a query_string (%r)" % (self.script, query_string)) + script, query_string = script.split('?', 1) if os.path.abspath(script) != script: # relative path for path_dir in self.path: @@ -41,11 +46,6 @@ class CGIApplication(object): else: self.script = script self.include_os_environ = include_os_environ - if '?' in self.script: - assert query_string is None, ( - "You cannot have '?' in your script name (%r) and also " - "give a query_string (%r)" % (self.script, query_string)) - self.script, query_string = self.script.split('?', 1) self.query_string = query_string def __call__(self, environ, start_response): @@ -67,6 +67,7 @@ class CGIApplication(object): if old: old += '&' cgi_environ['QUERY_STRING'] = old + self.query_string + cgi_environ['SCRIPT_FILENAME'] = self.script proc = subprocess.Popen( [self.script], stdin=subprocess.PIPE, @@ -75,11 +76,14 @@ class CGIApplication(object): env=cgi_environ, cwd=os.path.dirname(self.script), ) + writer = CGIWriter(environ, start_response) proc_communicate( proc, stdin=StdinReader.from_environ(environ), - stdout=CGIWriter(environ, start_response), + stdout=writer, stderr=environ['wsgi.errors']) + if not writer.headers_finished: + start_response(writer.status, writer.headers) return [] class CGIWriter(object): |