Class HttpResponseDuplicator

  • All Implemented Interfaces:
    SafeCloseable, AutoCloseable

    public class HttpResponseDuplicator
    extends AbstractStreamMessageDuplicator<HttpObject,​HttpResponse>
    Allows subscribing to an HttpResponse multiple times by duplicating the stream.
    
     > final HttpResponse originalRes = ...
     > final HttpResponseDuplicator resDuplicator = new HttpResponseDuplicator(originalRes);
     >
     > final HttpResponse dupRes1 = resDuplicator.duplicateStream();
     > final HttpResponse dupRes2 = resDuplicator.duplicateStream(true); // the last stream
     >
     > dupRes1.subscribe(new FooHeaderSubscriber() {
     >     @Override
     >     public void onNext(Object o) {
     >     ...
     >     // Do something according to the header's status.
     >     }
     > });
     >
     > dupRes2.aggregate().handle((aRes, cause) -> {
     >     // Do something with the message.
     > });