summaryrefslogtreecommitdiff
path: root/wsgitools/scgi/asynchronous.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2012-06-29 07:38:57 +0200
committerHelmut Grohne <helmut@subdivi.de>2012-06-29 19:18:39 +0200
commitd43d3d8947964392644b84ec1bce76c6f4193bea (patch)
treecfa2eae5ea7073396933883ad852656fdfff8163 /wsgitools/scgi/asynchronous.py
parentdd015aa622b25f8638ab0a13b5d75004d16004c8 (diff)
downloadwsgitools-d43d3d8947964392644b84ec1bce76c6f4193bea.tar.gz
scgi.asynchronous: move {en,de}coding to internal module
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()
-