[Twisted-Python] [PATCH] http.py: to allow setting the message of the status header
Manuel Estrada Sainz
ranty-bulk at ranty.ddts.net
Wed Jul 10 05:46:51 EDT 2002
Itamar, here it is as promised, if you don't like the way it is done,
just say so and I will rework it as needed.
Well, I didn't even test it, if you like the aproach I will start using
it in apt-proxy and report. But it is very small patch, I hopefully am
not dumb enough to fuck up in such a little thing.
Twisted rocks
ranty
--
--- Manuel Estrada Sainz <ranty at debian.org>
<ranty at bigfoot.com>
<ranty at users.sourceforge.net>
------------------------ <manuel.estrada at hispalinux.es> -------------------
God grant us the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.
-------------- next part --------------
Index: http.py
===================================================================
RCS file: /cvs/Twisted/twisted/protocols/http.py,v
retrieving revision 1.27
diff -u -r1.27 http.py
--- http.py 9 Jul 2002 21:40:24 -0000 1.27
+++ http.py 10 Jul 2002 09:37:16 -0000
@@ -296,6 +296,7 @@
producer = None
finished = 0
code = OK
+ code_message = None
method = "(no method yet)"
clientproto = "(no clientproto yet)"
uri = "(no uri yet)"
@@ -498,7 +499,10 @@
version = self.clientproto
if version != "HTTP/0.9":
l = []
- message = RESPONSES.get(self.code, "Unknown Status")
+ if self.code_message:
+ message = self.code_message
+ else:
+ message = RESPONSES.get(self.code, "Unknown Status")
l.append('%s %s %s\r\n' % (version, self.code, message))
# if we don't have a content length, we sent data in chunked mode,
# so that we can support pipelining in persistent connections.
@@ -549,10 +553,11 @@
cookie = cookie +"; Secure"
self.cookies.append(cookie)
- def setResponseCode(self, code):
+ def setResponseCode(self, code, message=None):
"""Set the HTTP response code.
"""
self.code = code
+ self.code_message = message
def setHeader(self, k, v):
"""Set an outgoing HTTP header.
More information about the Twisted-Python
mailing list