diff options
author | Marcel Hellkamp <marc@gsites.de> | 2012-10-17 23:18:43 +0200 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2012-10-17 23:18:43 +0200 |
commit | 5438a62cd2f2f3150d812b2e9b1d7995e46e9db5 (patch) | |
tree | 2fd6399660289c1cbcd5854074e071e2220acc6f | |
parent | c3dd6f5f09537f39e2b6f68b295de8f7518f7122 (diff) | |
download | bottle-5438a62cd2f2f3150d812b2e9b1d7995e46e9db5.tar.gz |
fix #386: Response cookies cleared after redirect()
redirect() creates a new HTTPResponse and that replaces headers or cookies defined on the global response object. This is the correct behavior. The old behavior was a bug, actually.
This patch restores the old (buggy) behavior for 0.11 to maintain backwards compatibility.
-rw-r--r-- | bottle.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -2044,7 +2044,10 @@ def redirect(url, code=None): if code is None: code = 303 if request.get('SERVER_PROTOCOL') == "HTTP/1.1" else 302 location = urljoin(request.url, url) - raise HTTPResponse("", status=code, Location=location) + res = HTTPResponse("", status=code, Location=location) + if response._cookies: + res._cookies = response._cookies + raise res def _file_iter_range(fp, offset, bytes, maxread=1024*1024): |