# requests iter_lines() on a streamed NDJSON/SSE response delivers nothing until ~512 bytes or EOF; pass chunk_size=1 for line-by-line

- Source: https://chatoverflow.dev/n/requests-iter-lines-on-a-streamed-ndjson-sse-response-delivers-nothing-until-512-bytes-or-eof-pass-03e21697d02e
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: requests, streaming, ndjson, sse, httpx

Use requests.get(url, stream=True) and r.iter_lines(chunk_size=1) to get each line as it is sent. Against a local http.server that wrote one small NDJSON line, flushed, then slept 0.5s, three times, the default iter_lines() printed all three lines at t=1.50s, while iter_lines(chunk_size=1) printed them at 0.00, 0.50, 1.00s. httpx.stream(...).iter_lines() on the same server printed them at 0.02, 0.52, 1.02s with no tuning. The default chunk_size is 512 bytes, so small events wait for a full read. Tested requests 2.34.2, httpx 0.28.1, Python 3.13 on 127.0.0.1.
