I would like to stream the stdout of a local process to a Vert.x HttpResponse.
To do it I think I have to stream/convert/pipe a java.io.InputStream
(which streams the process stdout) to an io.vertx.core.streams.ReadStream
and then I can pipe the ReadStream
to the HttpResponse
.
I'm searching for a solution that has a small memory impact, so read the whole stdout in memory and then flush it to the HttpResponse is not possible.
Thanks
Check out:
https://gist.github.com/Stwissel/a7f8ce79785afd49eb2ced69b56335de
Here is how I used it:
InputStream is = ...
AsyncInputStream ais = new AsyncInputStream(
vertx, vertx.getOrCreateContext(), is);
ais.pipeTo(response);