CChunkRavel
Product

Product features · Restricted chunked-body decoding

01

Inspect size-line parsing separately from payload copying, with the accepted subset visible beside the proposed decoder changes.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Restricted chunked-body decoding

● ● ●ChunkRavel●
A concrete starting point · Restricted chunked-body decoding ×
def chunk_body(wire):
    if type(wire) is not bytes or len(wire) > 65536:
        raise ValueError("bounded bytes")
    pos, body = 0, bytearray()
    while True:
        end = wire.find(b"\r\n", pos)
        token = wire[pos:end] if end >= 0 else b""
        if not 1 <= len(token) <= 8 or any(
            c not in b"0123456789abcdefABCDEF" for c in token):
            raise ValueError("plain hexadecimal size")
        size, pos = int(token, 16), end + 2
        if size == 0:
            if wire[pos:] != b"\r\n":
                raise ValueError("no trailers or extra bytes")
            return bytes(body)
        if len(body) + size > 4096:
            raise ValueError("body limit")
        if pos + size + 2 > len(wire):
            raise ValueError("truncated chunk")
        if wire[pos + size:pos + size + 2] != b"\r\n":
            raise ValueError("chunk delimiter")
        body.extend(wire[pos:pos + size])
        pos += size + 2
✳Decode a restricted chunked body from at most 65536 bytes with a 4096-byte output limit.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗