Reads body part data. :param bool decode: Decodes data following by encoding method from `Content-Encoding` header. If it missed data remains untouched :rtype: bytearray
(self, *, decode=False)
| 237 | |
| 238 | @asyncio.coroutine |
| 239 | def read(self, *, decode=False): |
| 240 | """Reads body part data. |
| 241 | |
| 242 | :param bool decode: Decodes data following by encoding |
| 243 | method from `Content-Encoding` header. If it missed |
| 244 | data remains untouched |
| 245 | |
| 246 | :rtype: bytearray |
| 247 | """ |
| 248 | if self._at_eof: |
| 249 | return b'' |
| 250 | data = bytearray() |
| 251 | if self._length is None: |
| 252 | while not self._at_eof: |
| 253 | data.extend((yield from self.readline())) |
| 254 | else: |
| 255 | while not self._at_eof: |
| 256 | data.extend((yield from self.read_chunk(self.chunk_size))) |
| 257 | if decode: |
| 258 | return self.decode(data) |
| 259 | return data |
| 260 | |
| 261 | @asyncio.coroutine |
| 262 | def read_chunk(self, size=chunk_size): |