diff --git a/CHANGES/4677.bugfix b/CHANGES/4677.bugfix new file mode 100644 index 00000000000..c70c3750055 --- /dev/null +++ b/CHANGES/4677.bugfix @@ -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 diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 756db268abe..2472790f63a 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -115,6 +115,7 @@ Gennady Andreyev Georges Dubus Greg Holt Gregory Haynes +Grigory Kirillov Gus Goulart Gustavo Carneiro Günther Jena diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 594a4cd1f9e..2ef5dc3ac8f 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -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' diff --git a/aiohttp/http_parser.py b/aiohttp/http_parser.py index 0a3da5bf38a..28cfafac745 100644 --- a/aiohttp/http_parser.py +++ b/aiohttp/http_parser.py @@ -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