Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test invalid chunked body #10587

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
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