From 1c9e7b982a7d3fe76f5bd03e53b21b9d450f4607 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 14 Jul 2011 15:59:27 +1200 Subject: Rewrite Headers object to preserve order and case. --- libmproxy/flow.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libmproxy/flow.py') diff --git a/libmproxy/flow.py b/libmproxy/flow.py index be77af33..d29b8e2d 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -101,7 +101,7 @@ class ServerPlaybackState: if self.headers: hdrs = [] for i in self.headers: - v = r.headers.get(i, []) + v = r.headers[i] # Slightly subtle: we need to convert everything to strings # to prevent a mismatch between unicode/non-unicode. v = [str(x) for x in v] @@ -139,7 +139,7 @@ class StickyCookieState: ) def handle_response(self, f): - for i in f.response.headers.get("set-cookie", []): + for i in f.response.headers["set-cookie"]: # FIXME: We now know that Cookie.py screws up some cookies with # valid RFC 822/1123 datetime specifications for expiry. Sigh. c = Cookie.SimpleCookie(i) @@ -158,9 +158,10 @@ class StickyCookieState: f.request.path.startswith(i[2]) ] if all(match): - l = f.request.headers.setdefault("cookie", []) + l = f.request.headers["cookie"] f.request.stickycookie = True l.append(self.jar[i].output(header="").strip()) + f.request.headers["cookie"] = l class StickyAuthState: -- cgit v1.2.3