MCPcopy
hub / github.com/encode/uvicorn / test_invalid_header_name

Function test_invalid_header_name

tests/protocols/test_http.py:333–342  ·  view source on GitHub ↗
(http_protocol_cls: type[HTTPProtocol], name: str)

Source from the content-addressed store, hash-verified

331 ],
332)
333async def test_invalid_header_name(http_protocol_cls: type[HTTPProtocol], name: str):
334 app = Response("Hello, world", media_type="text/plain", headers={name: "value"})
335 protocol = get_connected_protocol(app, http_protocol_cls)
336 protocol.data_received(SIMPLE_GET_REQUEST)
337 await protocol.loop.run_one()
338 # No 500 is sent because `response_started` is set before header validation,
339 # so the error handler just closes the connection.
340 assert b"HTTP/1.1 500 Internal Server Error" not in protocol.transport.buffer
341 assert name.encode() not in protocol.transport.buffer
342 assert protocol.transport.is_closing()
343
344
345@pytest.mark.parametrize("path", ["/", "/?foo", "/?foo=bar", "/?foo=bar&baz=1"])

Callers

nothing calls this directly

Calls 5

ResponseClass · 0.90
get_connected_protocolFunction · 0.70
data_receivedMethod · 0.45
run_oneMethod · 0.45
is_closingMethod · 0.45

Tested by

no test coverage detected