summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2012-10-17 23:18:43 +0200
committerMarcel Hellkamp <marc@gsites.de>2012-10-17 23:18:43 +0200
commit5438a62cd2f2f3150d812b2e9b1d7995e46e9db5 (patch)
tree2fd6399660289c1cbcd5854074e071e2220acc6f
parentc3dd6f5f09537f39e2b6f68b295de8f7518f7122 (diff)
downloadbottle-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.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/bottle.py b/bottle.py
index 519023b..c1556b1 100644
--- a/bottle.py
+++ b/bottle.py
@@ -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):