many iteritems optimizations

This commit is contained in:
mdipierro
2012-08-28 09:35:36 -05:00
parent 18a2c2c68e
commit f9e35599c6
10 changed files with 147 additions and 108 deletions
+3 -4
View File
@@ -92,14 +92,13 @@ class HTTP(BaseException):
body += '<!-- %s //-->' % ('x'*512) ### trick IE
self.headers['Content-Length'] = len(body)
headers = []
for (k, v) in self.headers.items():
for k, v in self.headers.iteritems():
if isinstance(v, list):
for item in v:
headers.append((k, str(item)))
headers += [(k, str(item)) for item in v]
else:
headers.append((k, str(v)))
responder(status, headers)
if hasattr(body, '__iter__') and not isinstance(self.body, str):
if hasattr(body, '__iter__') and not isinstance(self.body,str):
return body
return [str(body)]