diff options
| author | Ujjwal Verma <ujjwalverma1111@gmail.com> | 2017-05-10 15:40:30 +0530 | 
|---|---|---|
| committer | Ujjwal Verma <ujjwalverma1111@gmail.com> | 2017-05-12 21:09:50 +0530 | 
| commit | 9d0771bae59497dc2282f555f1a6ac7422e444d1 (patch) | |
| tree | 63c31772e1643f21d664dc3e31c32c695fe85b81 | |
| parent | 766c5caea87d49f8fa2d807f6d954ca68e086231 (diff) | |
| download | mitmproxy-9d0771bae59497dc2282f555f1a6ac7422e444d1.tar.gz mitmproxy-9d0771bae59497dc2282f555f1a6ac7422e444d1.tar.bz2 mitmproxy-9d0771bae59497dc2282f555f1a6ac7422e444d1.zip | |
net.http.url.py changes
| -rw-r--r-- | mitmproxy/net/http/url.py | 24 | 
1 files changed, 3 insertions, 21 deletions
| diff --git a/mitmproxy/net/http/url.py b/mitmproxy/net/http/url.py index f2c8c473..86f65cfd 100644 --- a/mitmproxy/net/http/url.py +++ b/mitmproxy/net/http/url.py @@ -5,22 +5,6 @@ from typing import Tuple  from mitmproxy.net import check -# PY2 workaround -def decode_parse_result(result, enc): -    if hasattr(result, "decode"): -        return result.decode(enc) -    else: -        return urllib.parse.ParseResult(*[x.decode(enc) for x in result]) - - -# PY2 workaround -def encode_parse_result(result, enc): -    if hasattr(result, "encode"): -        return result.encode(enc) -    else: -        return urllib.parse.ParseResult(*[x.encode(enc) for x in result]) - -  def parse(url):      """          URL-parsing function that checks that @@ -47,12 +31,12 @@ def parse(url):          # this should not raise a ValueError,          # but we try to be very forgiving here and accept just everything. -        # decode_parse_result(parsed, "ascii")      else:          host = parsed.hostname.encode("idna") -        parsed = encode_parse_result(parsed, "ascii") +        if isinstance(parsed, urllib.parse.ParseResult): +            parsed = parsed.encode("ascii") -    port = parsed.port +    port = parsed.port  # Returns None if port number invalid in Py3.5. Will throw ValueError in Py3.6      if not port:          port = 443 if parsed.scheme == b"https" else 80 @@ -64,8 +48,6 @@ def parse(url):      if not check.is_valid_host(host):          raise ValueError("Invalid Host") -    if not check.is_valid_port(port): -        raise ValueError("Invalid Port")      return parsed.scheme, host, port, full_path | 
