mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
preserve content-type parameter order
This commit is contained in:
parent
3602fd7a36
commit
e6e39ce80f
@ -2,6 +2,7 @@ from __future__ import absolute_import, print_function, division
|
||||
|
||||
import re
|
||||
|
||||
import collections
|
||||
import six
|
||||
from netlib import multidict
|
||||
from netlib import strutils
|
||||
@ -206,7 +207,7 @@ def parse_content_type(c):
|
||||
ts = parts[0].split("/", 1)
|
||||
if len(ts) != 2:
|
||||
return None
|
||||
d = {}
|
||||
d = collections.OrderedDict()
|
||||
if len(parts) == 2:
|
||||
for i in parts[1].split(";"):
|
||||
clause = i.split("=", 1)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import collections
|
||||
|
||||
from netlib.http.headers import Headers, parse_content_type, assemble_content_type
|
||||
from netlib.tutils import raises
|
||||
|
||||
@ -87,4 +89,4 @@ def test_assemble_content_type():
|
||||
p = assemble_content_type
|
||||
assert p("text", "html", {}) == "text/html"
|
||||
assert p("text", "html", {"charset": "utf8"}) == "text/html; charset=utf8"
|
||||
assert p("text", "html", {"charset": "utf8", "foo": "bar"}) == "text/html; charset=utf8; foo=bar"
|
||||
assert p("text", "html", collections.OrderedDict([("charset", "utf8"), ("foo", "bar")])) == "text/html; charset=utf8; foo=bar"
|
||||
|
Loading…
Reference in New Issue
Block a user