- java.lang.Object
-
- com.github.mizosoft.methanol.decoder.AsyncBodyDecoder<T>
-
- All Implemented Interfaces:
BodyDecoder<T>,java.net.http.HttpResponse.BodySubscriber<T>,java.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
public final class AsyncBodyDecoder<T> extends java.lang.Object implements BodyDecoder<T>
An implementation ofBodyDecoderthat uses anAsyncDecoderfor decompression. The implementation disallows left-over bytes after the final source is acknowledged, completing the downstream with anIOExceptionon 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
Constructors Constructor Description AsyncBodyDecoder(AsyncDecoder decoder, java.net.http.HttpResponse.BodySubscriber<T> downstream)Creates anAsyncBodyDecoderin sync mode.AsyncBodyDecoder(AsyncDecoder decoder, java.net.http.HttpResponse.BodySubscriber<T> downstream, java.util.concurrent.Executor executor)Creates anAsyncBodyDecoderthat supplies downstream items in the given executor.AsyncBodyDecoder(AsyncDecoder decoder, java.net.http.HttpResponse.BodySubscriber<T> downstream, java.util.concurrent.Executor executor, int bufferSize)Creates anAsyncBodyDecoderthat supplies downstream items in the given executor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncDecoderasyncDecoder()Returns the underlyingAsyncDecoder.java.net.http.HttpResponse.BodySubscriber<T>downstream()Returns this decoder's downstream.java.lang.Stringencoding()Returns the encoding used by this decoder.java.util.Optional<java.util.concurrent.Executor>executor()Returns this decoder's executor if one is specified.voidonComplete()voidonError(java.lang.Throwable throwable)voidonNext(java.util.List<java.nio.ByteBuffer> buffers)voidonSubscribe(java.util.concurrent.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 Detail
-
AsyncBodyDecoder
public AsyncBodyDecoder(AsyncDecoder decoder, java.net.http.HttpResponse.BodySubscriber<T> downstream)
Creates anAsyncBodyDecoderin sync mode.
-
AsyncBodyDecoder
public AsyncBodyDecoder(AsyncDecoder decoder, java.net.http.HttpResponse.BodySubscriber<T> downstream, java.util.concurrent.Executor executor)
Creates anAsyncBodyDecoderthat supplies downstream items in the given executor.
-
AsyncBodyDecoder
public AsyncBodyDecoder(AsyncDecoder decoder, java.net.http.HttpResponse.BodySubscriber<T> downstream, java.util.concurrent.Executor executor, int bufferSize)
Creates anAsyncBodyDecoderthat supplies downstream items in the given executor.
-
-
Method Detail
-
asyncDecoder
public AsyncDecoder asyncDecoder()
Returns the underlyingAsyncDecoder.
-
encoding
public java.lang.String encoding()
Description copied from interface:BodyDecoderReturns the encoding used by this decoder. This corresponds to the value of theContent-Typeheader.- Specified by:
encodingin interfaceBodyDecoder<T>
-
executor
public java.util.Optional<java.util.concurrent.Executor> executor()
Description copied from interface:BodyDecoderReturns this decoder's executor if one is specified.- Specified by:
executorin interfaceBodyDecoder<T>
-
downstream
public java.net.http.HttpResponse.BodySubscriber<T> downstream()
Description copied from interface:BodyDecoderReturns this decoder's downstream.- Specified by:
downstreamin interfaceBodyDecoder<T>
-
onSubscribe
public void onSubscribe(java.util.concurrent.Flow.Subscription upstreamSubscription)
- Specified by:
onSubscribein interfacejava.util.concurrent.Flow.Subscriber<T>
-
onNext
public void onNext(java.util.List<java.nio.ByteBuffer> buffers)
- Specified by:
onNextin interfacejava.util.concurrent.Flow.Subscriber<T>
-
onError
public void onError(java.lang.Throwable throwable)
- Specified by:
onErrorin interfacejava.util.concurrent.Flow.Subscriber<T>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfacejava.util.concurrent.Flow.Subscriber<T>
-
-