mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
* Fixes #4416 Fix ValueError when splitting on a request URI without a path part. * Fix mypy lintining issue * Replace .split() with .partition() for cleaner code
This commit is contained in:
parent
9763c1810d
commit
aebc40c408
@ -111,7 +111,7 @@ def _read_request_line(line: bytes) -> Tuple[str, int, bytes, bytes, bytes, byte
|
||||
raise ValueError
|
||||
else:
|
||||
scheme, rest = target.split(b"://", maxsplit=1)
|
||||
authority, path_ = rest.split(b"/", maxsplit=1)
|
||||
authority, _, path_ = rest.partition(b"/")
|
||||
path = b"/" + path_
|
||||
host, port = url.parse_authority(authority, check=True)
|
||||
port = port or url.default_port(scheme)
|
||||
|
@ -137,6 +137,8 @@ def test_read_request_line():
|
||||
("foo", 42, b"CONNECT", b"", b"foo:42", b"", b"HTTP/1.1"))
|
||||
assert (t(b"GET http://foo:42/bar HTTP/1.1") ==
|
||||
("foo", 42, b"GET", b"http", b"foo:42", b"/bar", b"HTTP/1.1"))
|
||||
assert (t(b"GET http://foo:42 HTTP/1.1") ==
|
||||
("foo", 42, b"GET", b"http", b"foo:42", b"/", b"HTTP/1.1"))
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
t(b"GET / WTF/1.1")
|
||||
|
Loading…
Reference in New Issue
Block a user