I am trying to understand a difference between below two snippets using rxRequest/rxSend vs request/send. They seem to behave in the same way.
RecordParser parser = RecordParser.newDelimited("\n", h -> log.info("r={}", h.toString()));
client
.rxRequest(HttpMethod.GET, sut.actualPort(), "localhost", "/stream?file=stream2.txt")
.flatMap(request -> request.rxSend().flatMap(HttpClientResponse::body))
.subscribe(
body -> {
parser.handle(body.getDelegate());
ctx.completeNow();
},
ctx::failNow);
// vs
RecordParser parser = RecordParser.newDelimited("\n", h -> log.info("r={}", h.toString()));
client
.request(HttpMethod.GET, sut.actualPort(), "localhost", "/stream?file=stream2.txt")
.flatMap(request -> request.send().flatMap(HttpClientResponse::body))
.subscribe(
body -> {
parser.handle(body.getDelegate());
ctx.completeNow();
},
ctx::failNow);
I understand that logic for rxRequest/rxSend is executed later at subscription time where request/send methods call the former methods and then subscribe immediately. What are practical examples when rxRequest/rxSend are needed and when not.