The problem is when I return chunked response following documentation with a number of random lines, not all of these lines appear in browser (Google Chrome, Postman). E.g. if I send 8192 lines the browser will show only ~7k or even ~4k. My goal is to generate large CSV file using this kind of approach.
public Result test() {
var source = Source.<ByteString>actorRef(256, OverflowStrategy.dropNew())
.mapMaterializedValue(actor -> {
new Thread(new MyRunnable(actor)).start();
return NotUsed.getInstance();
});
return ok().chunked(source);
}
// ------
public class MyRunnable implements Runnable {
private final ActorRef actor;
public MyRunnable(ActorRef actor) {
this.actor = actor;
}
public void run() {
for (var i = 0; i < 1024 * 8; i++) {
var line = String.format("%d some data goes here\n", i + 1);
actor.tell(ByteString.fromString(line), null);
}
actor.tell(new Status.Success(NotUsed.getInstance()), null);
}
}
Specify the content-length header as it seems play framework don't do it correctly .
quote