Skip to main content

Overview

Demonstrates opt-in, bounded capture of a streamed response. Capture is disabled by default so long-lived streams do not retain their response bodies in memory. The example uses a 10-byte preview limit: the complete stream is still emitted, but only its prefix is retained for inspection. For very long streams, prefer preview() with a small limit. chunks() and full() retain one PHP entry per captured chunk; 50,000–100,000 small chunks can therefore consume several times their payload size in array and string overhead, even with a byte cap. The default avoids that retention.

Example