Skip to content

Commit f51aa84

Browse files
committed
Test that the host idna encoding in the handshake works
This ensures that the byte representation is idna encoded and that the host is correctly decoded in the request instance.
1 parent 2afeb33 commit f51aa84

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/test_handshake.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ def test_successful_handshake() -> None:
2323
assert repr(server) == "H11Handshake(client=False, state=ConnectionState.OPEN)"
2424

2525

26+
def test_host_encoding() -> None:
27+
client = H11Handshake(CLIENT)
28+
server = H11Handshake(SERVER)
29+
data = client.send(Request(host="芝士汉堡", target="/"))
30+
assert b"Host: xn--7ks3rz39bh7u" in data
31+
server.receive_data(data)
32+
request = next(server.events())
33+
assert isinstance(request, Request)
34+
assert request.host == "芝士汉堡"
35+
36+
2637
@pytest.mark.parametrize("http", [b"HTTP/1.0", b"HTTP/1.1"])
2738
def test_rejected_handshake(http: bytes) -> None:
2839
server = H11Handshake(SERVER)

0 commit comments

Comments
 (0)