79520481

Date: 2025-03-19 14:31:47
Score: 2
Natty:
Report link

@tsegismont posted a comment that a answer for Vert.x httpClient/webClient process response chunk by chunk or as stream is still up to date and HttpClient should be used when HTTP streaming must be connected with RecordParser. It means second solution from the question is preferred:

RecordParser parser = RecordParser.newDelimited("\n", h -> log.info("r={}", h.toString()));
client
    .request(HttpMethod.GET, sut.actualPort(), "localhost", "/stream?file=stream1.txt")
    .compose(HttpClientRequest::send)
    .onComplete(
        ar -> {
          if (ar.succeeded()) {
            HttpClientResponse response = ar.result();
            response.handler(parser);
            response.endHandler(e -> ctx.completeNow());
          } else {
            ctx.failNow(ar.cause());
          }
        });

Ideally PR for Vert.x documentation should clarify it.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @tsegismont
  • Self-answer (0.5):
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: kodstark