py3 fixed http.to

This commit is contained in:
ilvalle
2016-06-21 22:24:33 +02:00
parent 476db87335
commit 3270d39596
11 changed files with 31 additions and 19 deletions
+2 -2
View File
@@ -110,7 +110,7 @@ class HTTP(Exception):
if status[:1] == '4':
if not body:
body = status
if isinstance(body, str):
if isinstance(body, (str, bytes, bytearray)):
headers['Content-Length'] = len(body)
rheaders = []
for k, v in iteritems(headers):
@@ -121,7 +121,7 @@ class HTTP(Exception):
responder(status, rheaders)
if env.get('request_method', '') == 'HEAD':
return ['']
elif isinstance(body, str):
elif isinstance(body, (str, bytes, bytearray)):
return [body]
elif hasattr(body, '__iter__'):
return body