(self, chunk: bytes)
| 471 | return future |
| 472 | |
| 473 | def _format_chunk(self, chunk: bytes) -> bytes: |
| 474 | if self._expected_content_remaining is not None: |
| 475 | self._expected_content_remaining -= len(chunk) |
| 476 | if self._expected_content_remaining < 0: |
| 477 | # Close the stream now to stop further framing errors. |
| 478 | self.stream.close() |
| 479 | raise httputil.HTTPOutputError( |
| 480 | "Tried to write more data than Content-Length" |
| 481 | ) |
| 482 | if self._chunking_output and chunk: |
| 483 | # Don't write out empty chunks because that means END-OF-STREAM |
| 484 | # with chunked encoding |
| 485 | return utf8("%x" % len(chunk)) + b"\r\n" + chunk + b"\r\n" |
| 486 | else: |
| 487 | return chunk |
| 488 | |
| 489 | def write(self, chunk: bytes) -> "Future[None]": |
| 490 | """Implements `.HTTPConnection.write`. |
no test coverage detected