# HG changeset patch # User Sylvain Thénault # Date 1273589306 -7200 # Node ID 07b32d9d8804c639ca44ff35f3d65bc7536283f6 # Parent e23d681193cde3be38ab87ee0ea7ff43b9e4f396 [twisted] we must set response code before starting to write the answer, else it's ignored diff -r e23d681193cd -r 07b32d9d8804 etwist/http.py --- a/etwist/http.py Tue May 11 16:26:29 2010 +0200 +++ b/etwist/http.py Tue May 11 16:48:26 2010 +0200 @@ -45,10 +45,11 @@ def _finalize(self): + # we must set code before writing anything, else it's too late + if self._code is not None: + self._twreq.setResponseCode(self._code) if self._stream is not None: self._twreq.write(str(self._stream)) - if self._code is not None: - self._twreq.setResponseCode(self._code) self._twreq.finish() def __repr__(self):