summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2019-12-08 20:28:13 +0100
committerMarcel Hellkamp <marc@gsites.de>2019-12-08 20:32:42 +0100
commit983dd706550ea99a9db08e6a037374bda19aa2a5 (patch)
tree2fd38406532f04ea7ffb97553d30afa0dc4b80c7
parent01b4f9c174e2f4f2845e9ba3519bdac329e5369f (diff)
downloadbottle-defnull-12-1125.tar.gz
Added tests for #1125 fix.defnull-12-1125
-rwxr-xr-xtest/test_wsgi.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/test_wsgi.py b/test/test_wsgi.py
index 72563fc..e999a88 100755
--- a/test/test_wsgi.py
+++ b/test/test_wsgi.py
@@ -2,7 +2,7 @@
import unittest
import bottle
from tools import ServerTestBase
-from bottle import tob
+from bottle import tob, HTTPResponse
class TestWsgi(ServerTestBase):
''' Tests for WSGI functionality, routing and output casting (decorators) '''
@@ -243,6 +243,27 @@ class TestRouteDecorator(ServerTestBase):
self.assertBody('before', '/test')
self.assertHeader('X-Hook', 'after', '/test')
+ def test_after_response_hook_can_set_headers(self):
+ """ Issue #1125 """
+
+ @bottle.route()
+ def test1():
+ return "test"
+ @bottle.route()
+ def test2():
+ return HTTPResponse("test", 200)
+ @bottle.route()
+ def test3():
+ raise HTTPResponse("test", 200)
+
+ @bottle.hook('after_request')
+ def hook():
+ bottle.response.headers["X-Hook"] = 'works'
+
+ for route in ("/test1", "/test2", "/test3"):
+ self.assertBody('test', route)
+ self.assertHeader('X-Hook', 'works', route)
+
def test_template(self):
@bottle.route(template='test {{a}} {{b}}')
def test(): return dict(a=5, b=6)