[twisted] we must set response code before starting to write the answer, else it's ignored stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 11 May 2010 16:48:26 +0200
branchstable
changeset 5513 07b32d9d8804
parent 5512 e23d681193cd
child 5514 3679015c0a50
[twisted] we must set response code before starting to write the answer, else it's ignored
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):