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

Add tests for parsing chunked data split before or in the final CRLF (#4630) #4651

Merged
merged 5 commits into from
Mar 25, 2020
Merged
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
49 changes: 49 additions & 0 deletions tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,55 @@ async def test_parse_chunked_payload_size_error(self, stream) -> None:
assert isinstance(out.exception(),
http_exceptions.TransferEncodingError)

@pytest.mark.xfail(
reason="see https://github.com/aio-libs/aiohttp/issues/4630"
)
async def test_parse_chunked_payload_split_end(self, protocol) -> None:
JustAnotherArchivist marked this conversation as resolved.
Show resolved Hide resolved
out = aiohttp.StreamReader(protocol, loop=None)
p = HttpPayloadParser(out, chunked=True)
p.feed_data(b'4\r\nasdf\r\n0\r\n')
p.feed_data(b'\r\n')

assert out.is_eof()
assert b'asdf' == b''.join(out._buffer)

@pytest.mark.xfail(
reason="see https://github.com/aio-libs/aiohttp/issues/4630"
)
async def test_parse_chunked_payload_split_end2(self, protocol) -> None:
out = aiohttp.StreamReader(protocol, loop=None)
p = HttpPayloadParser(out, chunked=True)
p.feed_data(b'4\r\nasdf\r\n0\r\n\r')
p.feed_data(b'\n')

assert out.is_eof()
assert b'asdf' == b''.join(out._buffer)

async def test_parse_chunked_payload_split_end_trailers(self,
protocol) -> None:
out = aiohttp.StreamReader(protocol, loop=None)
p = HttpPayloadParser(out, chunked=True)
p.feed_data(b'4\r\nasdf\r\n0\r\n')
p.feed_data(b'Content-MD5: 912ec803b2ce49e4a541068d495ab570\r\n')
p.feed_data(b'\r\n')

assert out.is_eof()
assert b'asdf' == b''.join(out._buffer)

@pytest.mark.xfail(
reason="see https://github.com/aio-libs/aiohttp/issues/4630"
)
async def test_parse_chunked_payload_split_end_trailers2(self,
protocol) -> None:
out = aiohttp.StreamReader(protocol, loop=None)
p = HttpPayloadParser(out, chunked=True)
p.feed_data(b'4\r\nasdf\r\n0\r\n')
p.feed_data(b'Content-MD5: 912ec803b2ce49e4a541068d495ab570\r\n\r')
p.feed_data(b'\n')

assert out.is_eof()
assert b'asdf' == b''.join(out._buffer)

async def test_http_payload_parser_length(self, stream) -> None:
out = aiohttp.FlowControlDataQueue(stream,
loop=asyncio.get_event_loop())
Expand Down