[bwcompat] also set response headers in error cases
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 25 Nov 2015 12:32:59 +0100
changeset 11607 5b36399b6b21
parent 11606 e245680acce3
child 11608 259fa3391c7b
[bwcompat] also set response headers in error cases I had this sitting around in my local copy, I don't remember why I needed this but it seems correct.
pyramid_cubicweb/bwcompat.py
--- a/pyramid_cubicweb/bwcompat.py	Mon Feb 29 16:16:33 2016 +0100
+++ b/pyramid_cubicweb/bwcompat.py	Wed Nov 25 12:32:59 2015 +0100
@@ -95,15 +95,17 @@
                 # for this exception) should be enough
                 # content = self.appli.ajax_error_handler(req, ex)
                 raise
+            finally:
+                # XXX CubicWebPyramidRequest.headers_out should
+                # access directly the pyramid response headers.
+                request.response.headers.clear()
+                for k, v in req.headers_out.getAllRawHeaders():
+                    for item in v:
+                        request.response.headers.add(k, item)
+
             if content is not None:
                 request.response.body = content
 
-            # XXX CubicWebPyramidRequest.headers_out should
-            # access directly the pyramid response headers.
-            request.response.headers.clear()
-            for k, v in req.headers_out.getAllRawHeaders():
-                for item in v:
-                    request.response.headers.add(k, item)
 
         except LogOut as ex:
             # The actual 'logging out' logic should be in separated function