support for HEAD requests

This commit is contained in:
mdipierro
2012-08-29 08:22:35 -05:00
parent edeb237777
commit 9861a33c72
3 changed files with 8 additions and 5 deletions
+4 -2
View File
@@ -76,7 +76,7 @@ class HTTP(BaseException):
self.headers['Set-Cookie'] = [
str(cookie)[11:] for cookie in cookies.values()]
def to(self, responder):
def to(self, responder, env={}):
status = self.status
headers = self.headers
if status in defined_status:
@@ -100,7 +100,9 @@ class HTTP(BaseException):
else:
rheaders.append((k, str(v)))
responder(status, rheaders)
if isinstance(body,str):
if env.get('request_method','')=='HEAD':
return ['']
elif isinstance(body,str):
return [body]
elif hasattr(body, '__iter__'):
return body