summaryrefslogtreecommitdiff
path: root/mimeparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'mimeparse.py')
-rw-r--r--mimeparse.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/mimeparse.py b/mimeparse.py
index f1677f9..2884b1d 100644
--- a/mimeparse.py
+++ b/mimeparse.py
@@ -18,6 +18,7 @@ Contents:
- best_match(): Choose the mime-type with the highest quality ('q')
from a list of candidates.
"""
+import cgi
from functools import reduce
__version__ = '1.5.2'
@@ -41,11 +42,7 @@ def parse_mime_type(mime_type):
('application', 'xhtml', {'q', '0.5'})
"""
- parts = mime_type.split(';')
- params = dict([tuple([s.strip() for s in param.split('=', 1)])
- for param in parts[1:]
- ])
- full_type = parts[0].strip()
+ full_type, params = cgi.parse_header(mime_type)
# Java URLConnection class sends an Accept header that includes a
# single '*'. Turn it into a legal wildcard.
if full_type == '*':