summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2017-04-18 08:41:25 -0700
committerDavid Lord <davidism@gmail.com>2017-04-18 08:41:25 -0700
commit3bc109cfd5edd149425d81720b3365d50b9bc46d (patch)
tree14151fa334352e38bf4bd9767c8b063089327b3b
parentd044aa47ff2024a63ba2b83290e726ffd7de74a4 (diff)
downloadwerkzeug-3bc109cfd5edd149425d81720b3365d50b9bc46d.tar.gz
test custom cookie max size
-rw-r--r--tests/test_http.py13
-rw-r--r--werkzeug/wrappers.py13
2 files changed, 20 insertions, 6 deletions
diff --git a/tests/test_http.py b/tests/test_http.py
index 21473505..c718459b 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -418,13 +418,20 @@ class TestHTTPUtility(object):
strict_eq(val, 'foo=bar; Domain=.foo.com; Path=/')
def test_cookie_maxsize(self):
- val = http.dump_cookie('foo', ('bar' * 1360) + 'b')
+ val = http.dump_cookie('foo', 'bar' * 1360 + 'b')
assert len(val) == 4093
with pytest.raises(ValueError) as excinfo:
- http.dump_cookie('foo', ('bar' * 1360) + 'ba')
+ http.dump_cookie('foo', 'bar' * 1360 + 'ba')
- assert ('Cookie too large' in str(excinfo))
+ assert 'Cookie too large' in str(excinfo)
+
+ with pytest.raises(ValueError) as excinfo:
+ # testing custom size, also demonstrating that the value is not the
+ # final size of the cookie
+ http.dump_cookie('foo', b'w' * 512, max_size=512)
+
+ assert 'the limit is 512 bytes' in str(excinfo)
class TestRange(object):
diff --git a/werkzeug/wrappers.py b/werkzeug/wrappers.py
index c77583c7..18c841f1 100644
--- a/werkzeug/wrappers.py
+++ b/werkzeug/wrappers.py
@@ -1084,9 +1084,16 @@ class BaseResponse(object):
supported by all browsers.
"""
self.headers.add('Set-Cookie', dump_cookie(
- key, value=value, max_age=max_age, expires=expires, path=path,
- domain=domain, secure=secure, httponly=httponly,
- charset=self.charset, max_size=self.max_cookie_size
+ key,
+ value=value,
+ max_age=max_age,
+ expires=expires,
+ path=path,
+ domain=domain,
+ secure=secure,
+ httponly=httponly,
+ charset=self.charset,
+ max_size=self.max_cookie_size
))
def delete_cookie(self, key, path='/', domain=None):