Module methanol

Class 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 a ReadableByteChannel. The channel is InterruptibleChannel and either closing it asynchronously or interrupting the reader thread causes blocks on read() 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletionStage<java.nio.channels.ReadableByteChannel> getBody()  
      void onComplete()  
      void onError​(java.lang.Throwable throwable)  
      void onNext​(java.util.List<java.nio.ByteBuffer> item)  
      void onSubscribe​(java.util.concurrent.Flow.Subscription subscription)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteChannelBodySubscriber

        public ByteChannelBodySubscriber()
    • Method Detail

      • getBody

        public java.util.concurrent.CompletionStage<java.nio.channels.ReadableByteChannel> getBody()
        Specified by:
        getBody in interface java.net.http.HttpResponse.BodySubscriber<java.nio.channels.ReadableByteChannel>
      • onSubscribe

        public void onSubscribe​(java.util.concurrent.Flow.Subscription subscription)
        Specified by:
        onSubscribe in interface java.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
      • onNext

        public void onNext​(java.util.List<java.nio.ByteBuffer> item)
        Specified by:
        onNext in interface java.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
      • onError

        public void onError​(java.lang.Throwable throwable)
        Specified by:
        onError in interface java.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>
      • onComplete

        public void onComplete()
        Specified by:
        onComplete in interface java.util.concurrent.Flow.Subscriber<java.util.List<java.nio.ByteBuffer>>