diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-02-16 02:02:40 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-02-16 02:02:40 +0100 |
commit | 2d569527f29f2d6b0c7c9e10e509a6822b69ee4f (patch) | |
tree | 716765da657fad75b031fefc5bfdf8e1d5cfc81b | |
parent | bc7db1be2d3b330bb515703659af43d5154eeb14 (diff) | |
parent | 718e298dba59fda841e18c464c6a208660760c05 (diff) | |
download | mitmproxy-2d569527f29f2d6b0c7c9e10e509a6822b69ee4f.tar.gz mitmproxy-2d569527f29f2d6b0c7c9e10e509a6822b69ee4f.tar.bz2 mitmproxy-2d569527f29f2d6b0c7c9e10e509a6822b69ee4f.zip |
Merge branch 'master' of https://github.com/mitmproxy/mitmproxy
-rw-r--r-- | netlib/netlib/http/request.py | 9 | ||||
-rw-r--r-- | test/netlib/http/test_request.py | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/netlib/netlib/http/request.py b/netlib/netlib/http/request.py index 0e0f88ce..b9076c0f 100644 --- a/netlib/netlib/http/request.py +++ b/netlib/netlib/http/request.py @@ -192,7 +192,8 @@ class Request(Message): def query(self, odict): query = utils.urlencode(odict.lst) scheme, netloc, path, params, _, fragment = urllib.parse.urlparse(self.url) - self.url = urllib.parse.urlunparse([scheme, netloc, path, params, query, fragment]) + _, _, _, self.path = utils.parse_url( + urllib.parse.urlunparse([scheme, netloc, path, params, query, fragment])) @property def cookies(self): @@ -223,7 +224,8 @@ 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.url = urllib.parse.urlunparse([scheme, netloc, path, params, query, fragment]) + _, _, _, self.path = utils.parse_url( + urllib.parse.urlunparse([scheme, netloc, path, params, query, fragment])) def anticache(self): """ @@ -350,4 +352,5 @@ class Request(Message): @form_out.setter def form_out(self, form_out): # pragma: nocover warnings.warn(".form_out is deprecated, use .first_line_format instead.", DeprecationWarning) - self.first_line_format = form_out
\ No newline at end of file + self.first_line_format = form_out + diff --git a/test/netlib/http/test_request.py b/test/netlib/http/test_request.py index 900b2cd1..7a6a9665 100644 --- a/test/netlib/http/test_request.py +++ b/test/netlib/http/test_request.py @@ -136,8 +136,10 @@ class TestRequestUtils(object): assert request.query.lst == [("bar", "42")] def test_set_query(self): - request = treq() + request = treq(host=b"foo", headers = Headers(host=b"bar")) request.query = ODict([]) + assert request.host == b"foo" + assert request.headers["host"] == b"bar" def test_get_cookies_none(self): request = treq() @@ -180,11 +182,14 @@ class TestRequestUtils(object): assert request.path_components == ["foo", "bar"] def test_set_path_components(self): - request = treq() + request = treq(host=b"foo", headers = Headers(host=b"bar")) request.path_components = ["foo", "baz"] assert request.path == "/foo/baz" request.path_components = [] assert request.path == "/" + request.query = ODict([]) + assert request.host == b"foo" + assert request.headers["host"] == b"bar" def test_anticache(self): request = treq() |