Read and return the request content.
(self)
| 480 | return self._content |
| 481 | |
| 482 | async def aread(self) -> bytes: |
| 483 | """ |
| 484 | Read and return the request content. |
| 485 | """ |
| 486 | if not hasattr(self, "_content"): |
| 487 | assert isinstance(self.stream, typing.AsyncIterable) |
| 488 | self._content = b"".join([part async for part in self.stream]) |
| 489 | if not isinstance(self.stream, ByteStream): |
| 490 | # If a streaming request has been read entirely into memory, then |
| 491 | # we can replace the stream with a raw bytes implementation, |
| 492 | # to ensure that any non-replayable streams can still be used. |
| 493 | self.stream = ByteStream(self._content) |
| 494 | return self._content |
| 495 | |
| 496 | def __repr__(self) -> str: |
| 497 | class_name = self.__class__.__name__ |