Newline-delimited JSON (NDJSON) streams a sequence of JSON values without prefixing each streamed item with data:. In a Spring endpoint, changing produces to application/ndjson preserves incremental delivery while simplifying client handling. section 3.4.3
Account for these implementation details when testing NDJSON streaming:
- Enable HTTPie streaming explicitly with --stream, because HTTPie does not infer streaming from application/ndjson. section 3.4.3
- Expect HTTPie to buffer streamed words until it gathers a complete line. section 3.4.3
- Avoid combining token streaming with output conversion when the final JSON document must remain complete before parsing. section 3.4.3
Streaming an ask endpoint
A controller can declare @PostMapping(path="/ask", produces="application/ndjson") and return a reactive Flux<String>. Testing with HTTPie requires --stream; the response arrives incrementally rather than as one completed document.
