This commit is contained in:
Maximilian Hils 2015-09-28 11:18:00 +02:00
parent 45f2ea33b2
commit 87566da3ba
3 changed files with 7 additions and 7 deletions

View File

@ -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()

View File

@ -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")

View File

@ -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")