diff options
author | Florian Weimer <fw@deneb.enyo.de> | 2005-12-15 11:34:35 +0000 |
---|---|---|
committer | Florian Weimer <fw@deneb.enyo.de> | 2005-12-15 11:34:35 +0000 |
commit | fcae623dfaf7f5c469d3ca89e9b9cbb34b37045c (patch) | |
tree | 5a2c24ac02eb511ff56337a4f4355d1abec9ed5d /lib/python/web_support.py | |
parent | 51baa45ddea6aa3779d02c4f8de7570a91c830c8 (diff) |
lib/python/web_support.py (BinaryResult):
New class.
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@3050 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'lib/python/web_support.py')
-rw-r--r-- | lib/python/web_support.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/python/web_support.py b/lib/python/web_support.py index de174bd510..aea05e2e84 100644 --- a/lib/python/web_support.py +++ b/lib/python/web_support.py @@ -571,6 +571,21 @@ class HTMLResult(Result): write("Content-Type: text/html\n\n%s\n" % self.doctype) self.contents.flatten(write) +class BinaryResult(Result): + """An object of this class combines a status code with HTML contents.""" + def __init__(self, contents, status=200, + mimetype='application/octet-stream'): + self.contents = contents + self.status = status + self.mimetype = mimetype + + def flatten(self, write): + """Invokes write for the response header and the binary data.""" + if self.status <> 200: + write("Status: %d\n" % self.status) + write("Content-Type: %s\n\n" % self.mimetype) + write(self.contents) + class WebService(Service): def __init__(self, socket_name): Service.__init__(self, socket_name) |