From 4408cef2a6d161bc2af77412920ade8bab648dbd Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 17 Mar 2012 20:16:12 +0100 Subject: deduplicate scgi.{asynchronous,forkpool} --- wsgitools/scgi/asynchronous.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'wsgitools/scgi/asynchronous.py') diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py index 6b69c73..4ecb00a 100644 --- a/wsgitools/scgi/asynchronous.py +++ b/wsgitools/scgi/asynchronous.py @@ -11,6 +11,8 @@ except ImportError: import StringIO as io import errno +from wsgitools.scgi import _convert_environ + if sys.version_info[0] >= 3: def exc_info_for_raise(exc_info): return exc_info[0](exc_info[1]).with_traceback(exc_info[2]) @@ -44,15 +46,6 @@ class SCGIConnection(asyncore.dispatcher): # () -> unset, (..,..) -> set, True -> sent self.body = io.StringIO() # request body - def _wsgi_headers(self): - return {"wsgi.version": (1, 0), - "wsgi.input": self.body, - "wsgi.errors": self.server.error, - "wsgi.url_scheme": "http", - "wsgi.multithread": False, - "wsgi.multiprocess": False, - "wsgi.run_once": False} - def _try_send_headers(self): if self.outheaders != True: assert not self.outbuff @@ -128,14 +121,9 @@ class SCGIConnection(asyncore.dispatcher): self.body.seek(0) self.inbuff = "" self.reqlen = 0 - self.environ.update(self._wsgi_headers()) - if self.environ.get("HTTPS", "no").lower() in ('yes', 'y', '1'): - self.environ["wsgi.url_scheme"] = "https" - if "HTTP_CONTENT_TYPE" in self.environ: - self.environ["CONTENT_TYPE"] = \ - self.environ.pop("HTTP_CONTENT_TYPE") - if "HTTP_CONTENT_LENGTH" in self.environ: - del self.environ["HTTP_CONTENT_LENGTH"] # TODO: better way? + _convert_environ(self.environ) + self.environ["wsgi.input"] = self.body + self.environ["wsgi.errors"] = self.server.error self.wsgihandler = iter(self.server.wsgiapp( self.environ, self.start_response)) self.state = SCGIConnection.REQ -- cgit v1.2.3