Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made CookieStorage account for the overhead added by the underlying c…

…ookie encoding

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12285 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 63d072581c62eb38d4b7f1dac3d261945f357546 1 parent 7f944a2
@spookylukey spookylukey authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 django/contrib/messages/storage/cookie.py
View
7 django/contrib/messages/storage/cookie.py
@@ -86,7 +86,12 @@ def _store(self, messages, response, remove_oldest=True, *args, **kwargs):
unstored_messages = []
encoded_data = self._encode(messages)
if self.max_cookie_size:
- while encoded_data and len(encoded_data) > self.max_cookie_size:
+ # data is going to be stored eventually by CompatCookie, which
+ # adds it's own overhead, which we must account for.
+ def stored_length(val):
+ return len(CompatCookie().value_encode(val)[1])
+
+ while encoded_data and stored_length(encoded_data) > self.max_cookie_size:
if remove_oldest:
unstored_messages.append(messages.pop(0))
else:
Please sign in to comment.
Something went wrong with that request. Please try again.