mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-03-25 16:35:37 +08:00
This commit is contained in:
@@ -218,11 +218,6 @@ def _get_first_line(rfile):
|
|||||||
raise HttpReadDisconnect("Remote disconnected")
|
raise HttpReadDisconnect("Remote disconnected")
|
||||||
if not line:
|
if not line:
|
||||||
raise HttpReadDisconnect("Remote disconnected")
|
raise HttpReadDisconnect("Remote disconnected")
|
||||||
line = line.strip()
|
|
||||||
try:
|
|
||||||
line.decode("ascii")
|
|
||||||
except ValueError:
|
|
||||||
raise HttpSyntaxException("Non-ascii characters in first line: {}".format(line))
|
|
||||||
return line.strip()
|
return line.strip()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -237,8 +237,9 @@ def parse_url(url):
|
|||||||
if isinstance(url, six.binary_type):
|
if isinstance(url, six.binary_type):
|
||||||
host = parsed.hostname
|
host = parsed.hostname
|
||||||
|
|
||||||
# this should not raise a ValueError
|
# this should not raise a ValueError,
|
||||||
decode_parse_result(parsed, "ascii")
|
# but we try to be very forgiving here and accept just everything.
|
||||||
|
# decode_parse_result(parsed, "ascii")
|
||||||
else:
|
else:
|
||||||
host = parsed.hostname.encode("idna")
|
host = parsed.hostname.encode("idna")
|
||||||
parsed = encode_parse_result(parsed, "ascii")
|
parsed = encode_parse_result(parsed, "ascii")
|
||||||
|
|||||||
@@ -211,6 +211,10 @@ def test_read_response_line():
|
|||||||
|
|
||||||
assert t(b"HTTP/1.1 200 OK") == (b"HTTP/1.1", 200, b"OK")
|
assert t(b"HTTP/1.1 200 OK") == (b"HTTP/1.1", 200, b"OK")
|
||||||
assert t(b"HTTP/1.1 200") == (b"HTTP/1.1", 200, b"")
|
assert t(b"HTTP/1.1 200") == (b"HTTP/1.1", 200, b"")
|
||||||
|
|
||||||
|
# https://github.com/mitmproxy/mitmproxy/issues/784
|
||||||
|
assert t(b"HTTP/1.1 200") == (b"HTTP/1.1 Non-Autoris\xc3\xa9", 200, b"")
|
||||||
|
|
||||||
with raises(HttpSyntaxException):
|
with raises(HttpSyntaxException):
|
||||||
assert t(b"HTTP/1.1")
|
assert t(b"HTTP/1.1")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user