mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 16:17:49 +00:00
This commit is contained in:
parent
45f2ea33b2
commit
87566da3ba
@ -218,11 +218,6 @@ def _get_first_line(rfile):
|
||||
raise HttpReadDisconnect("Remote disconnected")
|
||||
if not line:
|
||||
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()
|
||||
|
||||
|
||||
|
@ -237,8 +237,9 @@ def parse_url(url):
|
||||
if isinstance(url, six.binary_type):
|
||||
host = parsed.hostname
|
||||
|
||||
# this should not raise a ValueError
|
||||
decode_parse_result(parsed, "ascii")
|
||||
# this should not raise a ValueError,
|
||||
# but we try to be very forgiving here and accept just everything.
|
||||
# decode_parse_result(parsed, "ascii")
|
||||
else:
|
||||
host = parsed.hostname.encode("idna")
|
||||
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") == (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):
|
||||
assert t(b"HTTP/1.1")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user