[Twisted-Python] [PATCH] http.py: to allow setting the message of the status header
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@debian.org> <ranty@bigfoot.com> <ranty@users.sourceforge.net> ------------------------ <manuel.estrada@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. 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.
OK, I checked in support for setting message in response code - same API, slightly different implementation.
On Wed, Jul 10, 2002 at 07:12:04AM -0400, Itamar Shtull-Trauring wrote:
OK, I checked in support for setting message in response code - same API, slightly different implementation.
Your solution is more elegant than mine, I must admit. Thanks for the quick response ranty -- --- Manuel Estrada Sainz <ranty@debian.org> <ranty@bigfoot.com> <ranty@users.sourceforge.net> ------------------------ <manuel.estrada@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.
participants (2)
-
Itamar Shtull-Trauring
-
Manuel Estrada Sainz