Skip to content
Draft
Changes from 3 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
14 changes: 14 additions & 0 deletions tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,20 @@
assert payload.is_eof()


def test_parse_payload_response_with_invalid_body(
loop: asyncio.AbstractEventLoop,
protocol: BaseProtocol,
response_cls: Type[HttpResponseParser],
) -> None:
parser = response_cls(protocol, loop, 2**16, response_with_body=False)
text = (
b"HTTP/1.1 200 Ok\r\nTransfer-Encoding: chunked\r\n\r\n"
b"7\r\nchunked\r\n0\r\n\r\n"
)
with pytest.raises(http_exceptions.BadHttpMessage, match="status line"):
msg, payload = parser.feed_data(text)[0][0]


def test_parse_length_payload(response: HttpResponseParser) -> None:
text = b"HTTP/1.1 200 Ok\r\ncontent-length: 4\r\n\r\n"
msg, payload = response.feed_data(text)[0][0]
Expand Down
Loading