--- a/http.py Tue Feb 10 01:07:15 2009 +0200
+++ b/http.py Thu Feb 12 01:37:02 2009 +0200
@@ -165,10 +165,15 @@
def __init__ (self, data, content_type='text/html', status='200 OK', charset='UTF-8') :
"""
- Create the response. The Content-type header is built from the given values. The given \a data must be
- either a str (which is sent plain), an unicode object (which is encoded with the relevant charset), or
- None, whereupon an empty response body is sent. The content_type argument can also be forced to None to
- not send a Content-type header (e.g. for redirects)
+ Create the response. The Content-type header is built from the given values.
+
+ The given data must be a string-like object, which will be encoded with the given charset, or None,
+ whereupon an empty response body will be sent.
+
+ The content_type argument can also be forced to None to not send a Content-type header (e.g. for
+ redirects).
+
+ The charset can be given as None to not encode the output (for binary data).
"""
# store info
@@ -212,8 +217,12 @@
"""
if self.data :
- return self.data.encode(self.charset)
+ if self.charset :
+ return self.data.encode(self.charset)
+ else :
+ return self.data
+
else :
return ''