From 4b1d3de26d2f3269cb7cc1d404f7050c9b122cf4 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Mon, 22 Aug 2011 00:42:57 -0700 Subject: [PATCH] Allow multple different cookies to pass through the cleanup middleware. --- r2/r2/config/middleware.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/r2/r2/config/middleware.py b/r2/r2/config/middleware.py index 84520af0e..5d3b88ed1 100644 --- a/r2/r2/config/middleware.py +++ b/r2/r2/config/middleware.py @@ -458,7 +458,9 @@ class LimitUploadSize(object): return self.app(environ, start_response) - +# TODO CleanupMiddleware seems to exist because cookie headers are being duplicated +# somewhere in the response processing chain. It should be removed as soon as we +# find the underlying issue. class CleanupMiddleware(object): """ Put anything here that should be called after every other bit of @@ -475,9 +477,10 @@ class CleanupMiddleware(object): seen = set() for head, val in reversed(headers): head = head.lower() - if head not in seen: + key = (head, val.split("=", 1)[0]) + if key not in seen: fixed.insert(0, (head, val)) - seen.add(head) + seen.add(key) return start_response(status, fixed, exc_info) return self.app(environ, custom_start_response)