diff options
| author | Aldo Cortesi <aldo@corte.si> | 2016-10-20 12:36:26 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-20 12:36:26 +1300 |
| commit | 711078ba3f63257df745bb3edd80a85717e94b20 (patch) | |
| tree | d3116cd540faf01f272a0892fc6a9b83b4f6de8a /netlib/http/multipart.py | |
| parent | ee56d3fae0baeef1f31a83db122dd832d4c0e07e (diff) | |
| parent | 8430f857b504a3e7406dc36e54dc32783569d0dd (diff) | |
| download | mitmproxy-711078ba3f63257df745bb3edd80a85717e94b20.tar.gz mitmproxy-711078ba3f63257df745bb3edd80a85717e94b20.tar.bz2 mitmproxy-711078ba3f63257df745bb3edd80a85717e94b20.zip | |
Merge pull request #1637 from cortesi/tatanetlib
This PR merges netlib into mitmproxy
Diffstat (limited to 'netlib/http/multipart.py')
| -rw-r--r-- | netlib/http/multipart.py | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/netlib/http/multipart.py b/netlib/http/multipart.py deleted file mode 100644 index 536b2809..00000000 --- a/netlib/http/multipart.py +++ /dev/null @@ -1,32 +0,0 @@ -import re - -from netlib.http import headers - - -def decode(hdrs, content): - """ - Takes a multipart boundary encoded string and returns list of (key, value) tuples. - """ - v = hdrs.get("content-type") - if v: - v = headers.parse_content_type(v) - if not v: - return [] - try: - boundary = v[2]["boundary"].encode("ascii") - except (KeyError, UnicodeError): - return [] - - rx = re.compile(br'\bname="([^"]+)"') - r = [] - - for i in content.split(b"--" + boundary): - parts = i.splitlines() - if len(parts) > 1 and parts[0][0:2] != b"--": - match = rx.search(parts[1]) - if match: - key = match.group(1) - value = b"".join(parts[3 + parts[2:].index(b""):]) - r.append((key, value)) - return r - return [] |
