mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
fix #1120
This commit is contained in:
parent
01f52ee56a
commit
9d47d3b1ec
@ -162,7 +162,7 @@ class Request(Message):
|
||||
def path(self):
|
||||
"""
|
||||
HTTP request path, e.g. "/index.html".
|
||||
Guaranteed to start with a slash.
|
||||
Guaranteed to start with a slash, except for OPTIONS requests, which may just be "*".
|
||||
"""
|
||||
if self.data.path is None:
|
||||
return None
|
||||
|
@ -330,6 +330,8 @@ def unparse_url(scheme, host, port, path=""):
|
||||
Args:
|
||||
All args must be str.
|
||||
"""
|
||||
if path == "*":
|
||||
path = ""
|
||||
return "%s://%s%s" % (scheme, hostport(scheme, host, port), path)
|
||||
|
||||
|
||||
|
@ -107,6 +107,14 @@ class TestRequestUtils(object):
|
||||
with raises(ValueError):
|
||||
request.url = "not-a-url"
|
||||
|
||||
def test_url_options(self):
|
||||
request = treq(method="OPTIONS", path="*")
|
||||
assert request.url == "http://address:22"
|
||||
|
||||
def test_url_authority(self):
|
||||
request = treq(first_line_format="authority")
|
||||
assert request.url == "address:22"
|
||||
|
||||
def test_pretty_host(self):
|
||||
request = treq()
|
||||
# Without host header
|
||||
@ -140,6 +148,10 @@ class TestRequestUtils(object):
|
||||
request.headers["host"] = "other"
|
||||
assert request.pretty_url == "http://address:22/path"
|
||||
|
||||
def test_pretty_url_options(self):
|
||||
request = treq(method="OPTIONS", path="*")
|
||||
assert request.pretty_url == "http://address:22"
|
||||
|
||||
def test_pretty_url_authority(self):
|
||||
request = treq(first_line_format="authority")
|
||||
assert request.pretty_url == "address:22"
|
||||
|
Loading…
Reference in New Issue
Block a user