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):