Read body chunk asynchronously. Args: size: Maximum bytes to read Returns: bytes: Body data, empty bytes when body is exhausted
(self, size=8192)
| 130 | self._body_remaining = content_length |
| 131 | |
| 132 | async def read_body(self, size=8192): |
| 133 | """Read body chunk asynchronously. |
| 134 | |
| 135 | Args: |
| 136 | size: Maximum bytes to read |
| 137 | |
| 138 | Returns: |
| 139 | bytes: Body data, empty bytes when body is exhausted |
| 140 | """ |
| 141 | if self._body_remaining <= 0: |
| 142 | return b"" |
| 143 | to_read = min(size, self._body_remaining) |
| 144 | data = await self.unreader.read(to_read) |
| 145 | if data: |
| 146 | self._body_remaining -= len(data) |
| 147 | return data |
| 148 | |
| 149 | async def drain_body(self): |
| 150 | """Drain unread body data. |