Module methanol
Class ByteChannelBodySubscriber
- java.lang.Object
-
- com.github.mizosoft.methanol.internal.extensions.ByteChannelBodySubscriber
-
- All Implemented Interfaces:
java.net.http.HttpResponse.BodySubscriber<java.nio.channels.ReadableByteChannel>,java.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
public final class ByteChannelBodySubscriber extends java.lang.Object implements java.net.http.HttpResponse.BodySubscriber<java.nio.channels.ReadableByteChannel>A subscriber that exposes the flow of bytes as aReadableByteChannel. The channel isInterruptibleChanneland either closing it asynchronously or interrupting the reader thread causes blocks onread()to throw the appropriate exception and the upstream to be cancelled. Any errors received from upstream are immediately thrown when reading if detected, even if some bytes were available.
-
-
Constructor Summary
Constructors Constructor Description ByteChannelBodySubscriber()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletionStage<java.nio.channels.ReadableByteChannel>getBody()voidonComplete()voidonError(java.lang.Throwable throwable)voidonNext(java.util.List<java.nio.ByteBuffer> item)voidonSubscribe(java.util.concurrent.Flow.Subscription subscription)
-
-
-
Method Detail
-
getBody
public java.util.concurrent.CompletionStage<java.nio.channels.ReadableByteChannel> getBody()
- Specified by:
getBodyin interfacejava.net.http.HttpResponse.BodySubscriber<java.nio.channels.ReadableByteChannel>
-
onSubscribe
public void onSubscribe(java.util.concurrent.Flow.Subscription subscription)
- Specified by:
onSubscribein interfacejava.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
-
onNext
public void onNext(java.util.List<java.nio.ByteBuffer> item)
- Specified by:
onNextin interfacejava.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
-
onError
public void onError(java.lang.Throwable throwable)
- Specified by:
onErrorin interfacejava.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfacejava.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
-
-