Reputation: 349
I have application with vert.x and asyncHttpClient. I want to replace asyncHttpClient with vert.x httpClient (webClient), but i need to have ability to process response by chunks or by small parts of data (like org.asynchttpclient.AsyncHandler in AsyncHttpClient) or like a stream. Is it possible? I look at custom BodyCodec, but i can`t understand data flow in custom WriteStream.
Upvotes: 0
Views: 683
Reputation: 9128
You can't do this easily with Vert.x Web Client which is designed for buffering responses.
However you can do this with the Vert.x Http Client:
client.request(HttpMethod.GET, "some-uri", ar1 -> {
if (ar1.succeeded()) {
HttpClientRequest request = ar1.result();
request.send(ar2 -> {
HttpClientResponse response = ar2.result();
response.handler(buffer -> {
System.out.println("Received a part of the response body: " + buffer);
});
});
}
});
Upvotes: 2