Preserve explicit Connection header casing by Mirochill · Pull Request #195 · python-hyper/h11 · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions h11/_connection.py
17 changes: 17 additions & 0 deletions h11/tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,23 @@ def test_automagic_connection_close_handling() -> None:
assert conn.states == {CLIENT: MUST_CLOSE, SERVER: MUST_CLOSE}


def test_explicit_connection_close_preserves_header_case() -> None:
c = Connection(SERVER)
c.receive_data(
b"GET / HTTP/1.1\r\n"
b"Host: example.com\r\n"
b"Connection: close\r\n"
b"\r\n"
)
assert isinstance(c.next_event(), Request)
assert isinstance(c.next_event(), EndOfMessage)

assert (
c.send(Response(status_code=204, headers=[("connection", "close")]))
== b"HTTP/1.1 204 \r\nconnection: close\r\n\r\n"
)


def test_100_continue() -> None:
def setup() -> ConnectionPair:
p = ConnectionPair()
Expand Down
2 changes: 2 additions & 0 deletions newsfragments/156.bugfix.rst