aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-06-15 17:40:08 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-06-15 17:40:08 +1200
commitc7952371b718b6eb8d14e8fb8acddcdcbd8def5e (patch)
tree3b68562c0090370f04d3c4574cf4866f7ef817ba
parent8ae32708076efdf2bf88f5bb288e90c871eeec21 (diff)
downloadmitmproxy-c7952371b718b6eb8d14e8fb8acddcdcbd8def5e.tar.gz
mitmproxy-c7952371b718b6eb8d14e8fb8acddcdcbd8def5e.tar.bz2
mitmproxy-c7952371b718b6eb8d14e8fb8acddcdcbd8def5e.zip
Fix a problem in ODictCaseless that could cause duplicate headers.
-rw-r--r--libmproxy/flow.py5
-rw-r--r--test/test_flow.py6
2 files changed, 10 insertions, 1 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index e25460b5..21a8f3a2 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -142,6 +142,7 @@ class ODict:
return ret
def _filter_lst(self, k, lst):
+ k = self._kconv(k)
new = []
for i in lst:
if self._kconv(i[0]) != k:
@@ -163,7 +164,7 @@ class ODict:
raise ValueError("ODict valuelist should be lists.")
new = self._filter_lst(k, self.lst)
for i in valuelist:
- new.append((k, i))
+ new.append([k, i])
self.lst = new
def __delitem__(self, k):
@@ -478,6 +479,8 @@ class Request(HTTPMsg):
appropriate content-type header. Note that this will destory the
existing body if there is one.
"""
+ # FIXME: If there's an existing content-type header indicating a
+ # url-encoded form, leave it alone.
self.headers["Content-Type"] = [HDR_FORM_URLENCODED]
self.content = utils.urlencode(odict.lst)
diff --git a/test/test_flow.py b/test/test_flow.py
index 59d130f7..89577ddb 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -1052,6 +1052,12 @@ class TestODictCaseless:
def setUp(self):
self.od = flow.ODictCaseless()
+ def test_override(self):
+ o = flow.ODictCaseless()
+ o.add('T', 'application/x-www-form-urlencoded; charset=UTF-8')
+ o["T"] = ["foo"]
+ assert o["T"] == ["foo"]
+
def test_case_preservation(self):
self.od["Foo"] = ["1"]
assert "foo" in self.od