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