diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-08-09 22:15:58 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-08-10 21:04:17 +0200 |
commit | 891fa50e554963ef7cf236b087cfbedfaf19849e (patch) | |
tree | f6d0347829b3cc7d35027083655b0de3762cef74 /libmproxy/utils.py | |
parent | a10c31c6984f9b6646d2a7bad05ace912ea152a7 (diff) | |
download | mitmproxy-891fa50e554963ef7cf236b087cfbedfaf19849e.tar.gz mitmproxy-891fa50e554963ef7cf236b087cfbedfaf19849e.tar.bz2 mitmproxy-891fa50e554963ef7cf236b087cfbedfaf19849e.zip |
move code to netlib
Diffstat (limited to 'libmproxy/utils.py')
-rw-r--r-- | libmproxy/utils.py | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/libmproxy/utils.py b/libmproxy/utils.py index 22ab4344..3ac3cc01 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -61,34 +61,6 @@ def pretty_json(s): return json.dumps(p, sort_keys=True, indent=4).split("\n") -def multipartdecode(hdrs, content): - """ - Takes a multipart boundary encoded string and returns list of (key, value) tuples. - """ - v = hdrs.get_first("content-type") - if v: - v = parse_content_type(v) - if not v: - return [] - boundary = v[2].get("boundary") - if not boundary: - return [] - - rx = re.compile(r'\bname="([^"]+)"') - r = [] - - for i in content.split("--" + boundary): - parts = i.splitlines() - if len(parts) > 1 and parts[0][0:2] != "--": - match = rx.search(parts[1]) - if match: - key = match.group(1) - value = "".join(parts[3 + parts[2:].index(""):]) - r.append((key, value)) - return r - return [] - - def pretty_duration(secs): formatters = [ (100, "{:.0f}s"), @@ -154,34 +126,6 @@ class LRUCache: return ret -def parse_content_type(c): - """ - A simple parser for content-type values. Returns a (type, subtype, - parameters) tuple, where type and subtype are strings, and parameters - is a dict. If the string could not be parsed, return None. - - E.g. the following string: - - text/html; charset=UTF-8 - - Returns: - - ("text", "html", {"charset": "UTF-8"}) - """ - parts = c.split(";", 1) - ts = parts[0].split("/", 1) - if len(ts) != 2: - return None - d = {} - if len(parts) == 2: - for i in parts[1].split(";"): - clause = i.split("=", 1) - if len(clause) == 2: - d[clause[0].strip()] = clause[1].strip() - return ts[0].lower(), ts[1].lower(), d - - - def clean_hanging_newline(t): """ Many editors will silently add a newline to the final line of a |