(self, delegate: httputil.HTTPMessageDelegate)
| 664 | await ret |
| 665 | |
| 666 | async def _read_chunked_body(self, delegate: httputil.HTTPMessageDelegate) -> None: |
| 667 | # TODO: "chunk extensions" http://tools.ietf.org/html/rfc2616#section-3.6.1 |
| 668 | total_size = 0 |
| 669 | while True: |
| 670 | chunk_len_str = await self.stream.read_until(b"\r\n", max_bytes=64) |
| 671 | chunk_len = int(chunk_len_str.strip(), 16) |
| 672 | if chunk_len == 0: |
| 673 | crlf = await self.stream.read_bytes(2) |
| 674 | if crlf != b"\r\n": |
| 675 | raise httputil.HTTPInputError( |
| 676 | "improperly terminated chunked request" |
| 677 | ) |
| 678 | return |
| 679 | total_size += chunk_len |
| 680 | if total_size > self._max_body_size: |
| 681 | raise httputil.HTTPInputError("chunked body too large") |
| 682 | bytes_to_read = chunk_len |
| 683 | while bytes_to_read: |
| 684 | chunk = await self.stream.read_bytes( |
| 685 | min(bytes_to_read, self.params.chunk_size), partial=True |
| 686 | ) |
| 687 | bytes_to_read -= len(chunk) |
| 688 | if not self._write_finished or self.is_client: |
| 689 | with _ExceptionLoggingContext(app_log): |
| 690 | ret = delegate.data_received(chunk) |
| 691 | if ret is not None: |
| 692 | await ret |
| 693 | # chunk ends with \r\n |
| 694 | crlf = await self.stream.read_bytes(2) |
| 695 | assert crlf == b"\r\n" |
| 696 | |
| 697 | async def _read_body_until_close( |
| 698 | self, delegate: httputil.HTTPMessageDelegate |
no test coverage detected