java.lang.Object
com.github.mizosoft.methanol.decoder.AsyncBodyDecoder<T>
- All Implemented Interfaces:
BodyDecoder<T>
,HttpResponse.BodySubscriber<T>
,Flow.Subscriber<List<ByteBuffer>>
An implementation of
BodyDecoder
that uses an AsyncDecoder
for decompression. The
implementation disallows left-over bytes after the final source is acknowledged, completing the
downstream with an IOException
on such case. The decoder is closed on either normal or
exceptional completion or on cancellation from downstream.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.mizosoft.methanol.BodyDecoder
BodyDecoder.Factory
-
Constructor Summary
ConstructorDescriptionAsyncBodyDecoder
(AsyncDecoder decoder, HttpResponse.BodySubscriber<T> downstream) Creates anAsyncBodyDecoder
in sync mode.AsyncBodyDecoder
(AsyncDecoder decoder, HttpResponse.BodySubscriber<T> downstream, Executor executor) Creates anAsyncBodyDecoder
that supplies downstream items in the given executor.AsyncBodyDecoder
(AsyncDecoder decoder, HttpResponse.BodySubscriber<T> downstream, Executor executor, int bufferSize) Creates anAsyncBodyDecoder
that supplies downstream items in the given executor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlyingAsyncDecoder
.Returns this decoder's downstream.encoding()
Returns the encoding used by this decoder.executor()
Returns anOptional
containing this decoder's executor.void
void
void
onNext
(List<ByteBuffer> buffers) void
onSubscribe
(Flow.Subscription upstreamSubscription) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.mizosoft.methanol.BodyDecoder
getBody
-
Constructor Details
-
AsyncBodyDecoder
Creates anAsyncBodyDecoder
in sync mode. -
AsyncBodyDecoder
public AsyncBodyDecoder(AsyncDecoder decoder, HttpResponse.BodySubscriber<T> downstream, Executor executor) Creates anAsyncBodyDecoder
that supplies downstream items in the given executor. -
AsyncBodyDecoder
public AsyncBodyDecoder(AsyncDecoder decoder, HttpResponse.BodySubscriber<T> downstream, Executor executor, int bufferSize) Creates anAsyncBodyDecoder
that supplies downstream items in the given executor.
-
-
Method Details
-
asyncDecoder
Returns the underlyingAsyncDecoder
. -
encoding
Description copied from interface:BodyDecoder
Returns the encoding used by this decoder. Normally, this corresponds to the value of theContent-Type
header.- Specified by:
encoding
in interfaceBodyDecoder<T>
-
executor
Description copied from interface:BodyDecoder
Returns anOptional
containing this decoder's executor. An empty optional is returned if the decoder is in "synchronous" mode.- Specified by:
executor
in interfaceBodyDecoder<T>
-
downstream
Description copied from interface:BodyDecoder
Returns this decoder's downstream.- Specified by:
downstream
in interfaceBodyDecoder<T>
-
onSubscribe
- Specified by:
onSubscribe
in interfaceFlow.Subscriber<T>
-
onNext
- Specified by:
onNext
in interfaceFlow.Subscriber<T>
-
onError
- Specified by:
onError
in interfaceFlow.Subscriber<T>
-
onComplete
public void onComplete()- Specified by:
onComplete
in interfaceFlow.Subscriber<T>
-