MCPcopy
hub / github.com/aio-libs/aiohttp / read_chunk

Method read_chunk

aiohttp/multipart.py:262–282  ·  view source on GitHub ↗

Reads body part content chunk of the specified size. :param int size: chunk size :rtype: bytearray

(self, size=chunk_size)

Source from the content-addressed store, hash-verified

260
261 @asyncio.coroutine
262 def read_chunk(self, size=chunk_size):
263 """Reads body part content chunk of the specified size.
264
265 :param int size: chunk size
266
267 :rtype: bytearray
268 """
269 if self._at_eof:
270 return b''
271 if self._length:
272 chunk = yield from self._read_chunk_from_length(size)
273 else:
274 chunk = yield from self._read_chunk_from_stream(size)
275
276 self._read_bytes += len(chunk)
277 if self._read_bytes == self._length:
278 self._at_eof = True
279 if self._at_eof:
280 assert b'\r\n' == (yield from self._content.readline()), \
281 'reader did not read all the data or it is malformed'
282 return chunk
283
284 @asyncio.coroutine
285 def _read_chunk_from_length(self, size):

Calls 3

readlineMethod · 0.45