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

Fix last chunk #5058

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions CHANGES/4677.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if last chunk splitted 2 parts data_received(b'0\r\n') & data_received(b'\r\n') seted wrong state PARSE_TRAILERS
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Gennady Andreyev
Georges Dubus
Greg Holt
Gregory Haynes
Grigory Kirillov
Gus Goulart
Gustavo Carneiro
Günther Jena
Expand Down
5 changes: 4 additions & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,10 @@ def get_encoding(self) -> str:
except LookupError:
encoding = None
if not encoding:
if mimetype.type == 'application' and (mimetype.subtype == 'json' or mimetype.subtype == 'rdap'):
if (
mimetype.type == 'application' and
(mimetype.subtype == 'json' or mimetype.subtype == 'rdap')
):
# RFC 7159 states that the default encoding is UTF-8.
# RFC 7483 defines application/rdap+json
encoding = 'utf-8'
Expand Down
3 changes: 3 additions & 0 deletions aiohttp/http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ def feed_data(self,
# end of stream
self.payload.feed_eof()
return True, chunk[2:]
elif len(chunk) < 2:
self._chunk_tail = chunk
return False, b''
else:
self._chunk = ChunkState.PARSE_TRAILERS

Expand Down