public class HttpResponseDuplicator extends AbstractStreamMessageDuplicator<HttpObject,HttpResponse>
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.
> });
| Constructor and Description |
|---|
HttpResponseDuplicator(HttpResponse res)
Creates a new instance wrapping an
HttpResponse and publishing to multiple subscribers. |
HttpResponseDuplicator(HttpResponse res,
long maxSignalLength)
Creates a new instance wrapping an
HttpResponse and publishing to multiple subscribers. |
HttpResponseDuplicator(HttpResponse res,
long maxSignalLength,
io.netty.util.concurrent.EventExecutor executor)
Creates a new instance wrapping an
HttpResponse and publishing to multiple subscribers. |
| Modifier and Type | Method and Description |
|---|---|
HttpResponse |
duplicateStream()
Creates a new
StreamMessage that duplicates the upstream StreamMessage specified when
creating this duplicator. |
HttpResponse |
duplicateStream(boolean lastStream)
Creates a new
StreamMessage that duplicates the upstream StreamMessage specified when
creating this duplicator. |
abort, abort, close, duplicatorExecutorpublic HttpResponseDuplicator(HttpResponse res)
HttpResponse and publishing to multiple subscribers.
The length of response is limited by default with the client-side parameter which is
Flags.defaultMaxResponseLength(). If you are at server-side, you need to use
HttpResponseDuplicator(HttpResponse, long) and the long value should be greater than
the length of response or 0 which disables the limit.res - the response that will publish data to subscriberspublic HttpResponseDuplicator(HttpResponse res, long maxSignalLength)
HttpResponse and publishing to multiple subscribers.res - the response that will publish data to subscribersmaxSignalLength - the maximum length of signals. 0 disables the length limitpublic HttpResponseDuplicator(HttpResponse res, long maxSignalLength, @Nullable io.netty.util.concurrent.EventExecutor executor)
HttpResponse and publishing to multiple subscribers.res - the response that will publish data to subscribersmaxSignalLength - the maximum length of signals. 0 disables the length limitexecutor - the executor to use for upstream signals.public HttpResponse duplicateStream()
AbstractStreamMessageDuplicatorStreamMessage that duplicates the upstream StreamMessage specified when
creating this duplicator.duplicateStream in class AbstractStreamMessageDuplicator<HttpObject,HttpResponse>public HttpResponse duplicateStream(boolean lastStream)
AbstractStreamMessageDuplicatorStreamMessage that duplicates the upstream StreamMessage specified when
creating this duplicator.duplicateStream in class AbstractStreamMessageDuplicator<HttpObject,HttpResponse>lastStream - whether to prevent further duplicationCopyright © 2020 LeanCloud. All rights reserved.