MCPcopy
hub / github.com/benoitc/gunicorn / encode_chunk

Method encode_chunk

gunicorn/dirty/protocol.py:256–271  ·  view source on GitHub ↗

Encode a chunk message for streaming responses. Args: request_id: Request identifier this chunk belongs to data: Chunk data (must be TLV-serializable) Returns: bytes: Complete message (header + payload)

(request_id: int, data)

Source from the content-addressed store, hash-verified

254
255 @staticmethod
256 def encode_chunk(request_id: int, data) -> bytes:
257 """
258 Encode a chunk message for streaming responses.
259
260 Args:
261 request_id: Request identifier this chunk belongs to
262 data: Chunk data (must be TLV-serializable)
263
264 Returns:
265 bytes: Complete message (header + payload)
266 """
267 payload_dict = {"data": data}
268 payload = TLVEncoder.encode(payload_dict)
269 header = BinaryProtocol.encode_header(MSG_TYPE_CHUNK, request_id,
270 len(payload))
271 return header + payload
272
273 @staticmethod
274 def encode_end(request_id: int) -> bytes:

Callers 2

_encode_from_dictMethod · 0.80

Calls 2

encodeMethod · 0.80
encode_headerMethod · 0.80

Tested by 1