PythiloLesson 11 of 12 · progress kept in this browser

Reject oversized streams before buffering them

An input size limit is ineffective if the server reads the entire body before checking it. Enforce the byte budget incrementally while consuming chunks, and stop as soon as the accepted prefix plus the next chunk exceeds the bound.

Text characters and encoded bytes are different units. This exercise accepts byte chunks and returns exact bytes without decoding. It also tests that the producer is not consumed after rejection. A service must apply corresponding limits at ingress and decompression boundaries, because a small compressed request can expand far beyond its wire size.

text="я"
print(len(text))
print(len(text.encode("utf-8")))
Your task

Implement bounded_body(chunks,limit) joining byte chunks only while the cumulative length is <=limit. Reject negative limit or oversized input with ValueError; stop consuming immediately on overflow.