diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-05-31 18:46:19 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-05-31 18:46:19 +1200 |
commit | 6dda2b2ee544c3890f04b7bf99272998e29992b6 (patch) | |
tree | 67ed7ba9ce6d5266c93502653cf5f39be33d2bef /netlib | |
parent | 4e6c9c4e935458d23add259dc63c5e0a85fba9c8 (diff) | |
download | mitmproxy-6dda2b2ee544c3890f04b7bf99272998e29992b6.tar.gz mitmproxy-6dda2b2ee544c3890f04b7bf99272998e29992b6.tar.bz2 mitmproxy-6dda2b2ee544c3890f04b7bf99272998e29992b6.zip |
Module is part of the name - url.decode, not url.urldecode
A pattern we need to use far more often in the codebase
Diffstat (limited to 'netlib')
-rw-r--r-- | netlib/http/http1/read.py | 2 | ||||
-rw-r--r-- | netlib/http/http2/connections.py | 2 | ||||
-rw-r--r-- | netlib/http/request.py | 18 | ||||
-rw-r--r-- | netlib/http/url.py | 8 |
4 files changed, 15 insertions, 15 deletions
diff --git a/netlib/http/http1/read.py b/netlib/http/http1/read.py index f776d0b5..93fca04e 100644 --- a/netlib/http/http1/read.py +++ b/netlib/http/http1/read.py @@ -241,7 +241,7 @@ def _read_request_line(rfile): scheme, path = None, None else: form = "absolute" - scheme, host, port, path = url.parse_url(path) + scheme, host, port, path = url.parse(path) _check_http_version(http_version) except ValueError: diff --git a/netlib/http/http2/connections.py b/netlib/http/http2/connections.py index 4c15ee07..7c7ad693 100644 --- a/netlib/http/http2/connections.py +++ b/netlib/http/http2/connections.py @@ -118,7 +118,7 @@ class HTTP2Protocol(object): else: first_line_format = "absolute" # FIXME: verify if path or :host contains what we need - scheme, host, port, _ = url.parse_url(path) + scheme, host, port, _ = url.parse(path) scheme = scheme.decode('ascii') host = host.decode('ascii') diff --git a/netlib/http/request.py b/netlib/http/request.py index 170066f7..d552bc70 100644 --- a/netlib/http/request.py +++ b/netlib/http/request.py @@ -180,11 +180,11 @@ class Request(Message): """ if self.first_line_format == "authority": return "%s:%d" % (self.host, self.port) - return netlib.http.url.unparse_url(self.scheme, self.host, self.port, self.path) + return netlib.http.url.unparse(self.scheme, self.host, self.port, self.path) @url.setter def url(self, url): - self.scheme, self.host, self.port, self.path = netlib.http.url.parse_url(url) + self.scheme, self.host, self.port, self.path = netlib.http.url.parse(url) def _parse_host_header(self): """Extract the host and port from Host header""" @@ -220,7 +220,7 @@ class Request(Message): """ if self.first_line_format == "authority": return "%s:%d" % (self.pretty_host, self.port) - return netlib.http.url.unparse_url(self.scheme, self.pretty_host, self.port, self.path) + return netlib.http.url.unparse(self.scheme, self.pretty_host, self.port, self.path) @property def query(self): @@ -235,12 +235,12 @@ class Request(Message): def _get_query(self): _, _, _, _, query, _ = urllib.parse.urlparse(self.url) - return tuple(netlib.http.url.urldecode(query)) + return tuple(netlib.http.url.decode(query)) def _set_query(self, value): - query = netlib.http.url.urlencode(value) + query = netlib.http.url.encode(value) scheme, netloc, path, params, _, fragment = urllib.parse.urlparse(self.url) - _, _, _, self.path = netlib.http.url.parse_url( + _, _, _, self.path = netlib.http.url.parse( urllib.parse.urlunparse([scheme, netloc, path, params, query, fragment])) @query.setter @@ -288,7 +288,7 @@ class Request(Message): components = map(lambda x: urllib.parse.quote(x, safe=""), components) path = "/" + "/".join(components) scheme, netloc, _, params, query, fragment = urllib.parse.urlparse(self.url) - _, _, _, self.path = netlib.http.url.parse_url( + _, _, _, self.path = netlib.http.url.parse( urllib.parse.urlunparse([scheme, netloc, path, params, query, fragment])) def anticache(self): @@ -340,7 +340,7 @@ class Request(Message): def _get_urlencoded_form(self): is_valid_content_type = "application/x-www-form-urlencoded" in self.headers.get("content-type", "").lower() if is_valid_content_type: - return tuple(netlib.http.url.urldecode(self.content)) + return tuple(netlib.http.url.decode(self.content)) return () def _set_urlencoded_form(self, value): @@ -349,7 +349,7 @@ class Request(Message): This will overwrite the existing content if there is one. """ self.headers["content-type"] = "application/x-www-form-urlencoded" - self.content = netlib.http.url.urlencode(value) + self.content = netlib.http.url.encode(value) @urlencoded_form.setter def urlencoded_form(self, value): diff --git a/netlib/http/url.py b/netlib/http/url.py index 3961998b..147ed572 100644 --- a/netlib/http/url.py +++ b/netlib/http/url.py @@ -19,7 +19,7 @@ def encode_parse_result(result, enc): return urllib.parse.ParseResult(*[x.encode(enc) for x in result]) -def parse_url(url): +def parse(url): """ URL-parsing function that checks that - port is an integer 0-65535 @@ -68,7 +68,7 @@ def parse_url(url): return parsed.scheme, host, port, full_path -def unparse_url(scheme, host, port, path=""): +def unparse(scheme, host, port, path=""): """ Returns a URL string, constructed from the specified components. @@ -80,7 +80,7 @@ def unparse_url(scheme, host, port, path=""): return "%s://%s%s" % (scheme, utils.hostport(scheme, host, port), path) -def urlencode(s): +def encode(s): """ Takes a list of (key, value) tuples and returns a urlencoded string. """ @@ -88,7 +88,7 @@ def urlencode(s): return urllib.parse.urlencode(s, False) -def urldecode(s): +def decode(s): """ Takes a urlencoded string and returns a list of (key, value) tuples. """ |