MCPcopy Create free account
hub / github.com/EasyIME/PIME / _format_chunk

Method _format_chunk

python/python3/tornado/http1connection.py:472–486  ·  view source on GitHub ↗
(self, chunk: bytes)

Source from the content-addressed store, hash-verified

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

Callers 2

write_headersMethod · 0.95
writeMethod · 0.95

Calls 2

utf8Function · 0.90
closeMethod · 0.45

Tested by

no test coverage detected