summaryrefslogtreecommitdiff
path: root/wsgitools/scgi/asynchronous.py
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools/scgi/asynchronous.py')
-rw-r--r--wsgitools/scgi/asynchronous.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py
index 2c97f42..3009593 100644
--- a/wsgitools/scgi/asynchronous.py
+++ b/wsgitools/scgi/asynchronous.py
@@ -6,6 +6,7 @@ import socket
import sys
import errno
+from wsgitools.internal import bytes2str, str2bytes
from wsgitools.scgi import _convert_environ, FileWrapper
if sys.version_info[0] >= 3:
@@ -51,9 +52,7 @@ class SCGIConnection(asyncore.dispatcher):
status, headers = self.outheaders
headdata = "".join(map("%s: %s\r\n".__mod__, headers))
headdata = "Status: %s\r\n%s\r\n" % (status, headdata)
- if not isinstance(headdata, bytes):
- headdata = headdata.encode("iso-8859-1")
- self.outbuff = headdata
+ self.outbuff = str2bytes(headdata)
self.outheaders = True
def _wsgi_write(self, data):
@@ -98,10 +97,7 @@ class SCGIConnection(asyncore.dispatcher):
while buff.count(b'\0') >= 2:
key, value, buff = buff.split(b'\0', 2)
- if not isinstance(key, str):
- key = key.decode("iso-8859-1")
- value = value.decode("iso-8859-1")
- self.environ[key] = value
+ self.environ[bytes2str(key)] = bytes2str(value)
self.reqlen -= len(key) + len(value) + 2
self.inbuff = buff + remainder
@@ -276,4 +272,3 @@ class SCGIServer(asyncore.dispatcher):
"""Runs the server. It will not return and you can invoke
C{asyncore.loop()} instead achieving the same effect."""
asyncore.loop()
-