diff options
author | Marcel Hellkamp <marc@gsites.de> | 2013-01-21 13:18:58 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2013-01-21 13:26:08 +0100 |
commit | 0f193b092e1cf328e9b948455a342d9811150cd0 (patch) | |
tree | 381347575547f4787bba0c2a3934ddc6f3d93bf0 | |
parent | a96d69d3cf851245117b9118a534c08dbae9b06b (diff) | |
download | bottle-0f193b092e1cf328e9b948455a342d9811150cd0.tar.gz |
fix #438: "Some cookies are lost when using mount()"
Added support for multiple headers with the same name (e.g. Set-Cookie) for mounted apps.
-rw-r--r-- | bottle.py | 10 | ||||
-rw-r--r-- | test/test_mount.py | 11 |
2 files changed, 14 insertions, 7 deletions
@@ -561,14 +561,14 @@ class Bottle(object): def mountpoint_wrapper(): try: request.path_shift(path_depth) - rs = BaseResponse([], 200) - def start_response(status, header): + rs = HTTPResponse([]) + def start_response(status, headerlist): rs.status = status - for name, value in header: rs.add_header(name, value) + for name, value in headerlist: rs.add_header(name, value) return rs.body.append body = app(request.environ, start_response) - body = itertools.chain(rs.body, body) - return HTTPResponse(body, rs.status_code, **rs.headers) + if body: rs.body = itertools.chain(rs.body, body) + return rs finally: request.path_shift(-path_depth) diff --git a/test/test_mount.py b/test/test_mount.py index b67d5d8..ef1457a 100644 --- a/test/test_mount.py +++ b/test/test_mount.py @@ -1,6 +1,6 @@ import bottle from tools import ServerTestBase -from bottle import Bottle +from bottle import Bottle, response class TestAppMounting(ServerTestBase): def setUp(self): @@ -61,7 +61,14 @@ class TestAppMounting(ServerTestBase): self.assertBody('WSGI /', '/test/') self.assertHeader('X-Test', 'WSGI', '/test/') self.assertBody('WSGI /test/bar', '/test/test/bar') - + + def test_mount_wsgi(self): + @self.subapp.route('/cookie') + def test_cookie(): + response.set_cookie('a', 'a') + response.set_cookie('b', 'b') + self.app.mount('/test', self.subapp) + self.assertHeader('Set-Cookie', 'a=a, b=b', '/test/cookie') class TestAppMerging(ServerTestBase): def setUp(self): |