mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
Fix a problem in ODictCaseless that could cause duplicate headers.
This commit is contained in:
parent
8ae3270807
commit
c7952371b7
@ -142,6 +142,7 @@ class ODict:
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def _filter_lst(self, k, lst):
|
def _filter_lst(self, k, lst):
|
||||||
|
k = self._kconv(k)
|
||||||
new = []
|
new = []
|
||||||
for i in lst:
|
for i in lst:
|
||||||
if self._kconv(i[0]) != k:
|
if self._kconv(i[0]) != k:
|
||||||
@ -163,7 +164,7 @@ class ODict:
|
|||||||
raise ValueError("ODict valuelist should be lists.")
|
raise ValueError("ODict valuelist should be lists.")
|
||||||
new = self._filter_lst(k, self.lst)
|
new = self._filter_lst(k, self.lst)
|
||||||
for i in valuelist:
|
for i in valuelist:
|
||||||
new.append((k, i))
|
new.append([k, i])
|
||||||
self.lst = new
|
self.lst = new
|
||||||
|
|
||||||
def __delitem__(self, k):
|
def __delitem__(self, k):
|
||||||
@ -478,6 +479,8 @@ class Request(HTTPMsg):
|
|||||||
appropriate content-type header. Note that this will destory the
|
appropriate content-type header. Note that this will destory the
|
||||||
existing body if there is one.
|
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.headers["Content-Type"] = [HDR_FORM_URLENCODED]
|
||||||
self.content = utils.urlencode(odict.lst)
|
self.content = utils.urlencode(odict.lst)
|
||||||
|
|
||||||
|
@ -1052,6 +1052,12 @@ class TestODictCaseless:
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.od = flow.ODictCaseless()
|
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):
|
def test_case_preservation(self):
|
||||||
self.od["Foo"] = ["1"]
|
self.od["Foo"] = ["1"]
|
||||||
assert "foo" in self.od
|
assert "foo" in self.od
|
||||||
|
Loading…
Reference in New Issue
Block a user