Reads body part content chunk of the specified size. :param int size: chunk size :rtype: bytearray
(self, size=chunk_size)
| 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): |