Module methanol

Class 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 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.
    • Constructor Summary

      Constructors 
      Constructor Description
      AsyncBodyDecoder​(AsyncDecoder decoder, java.net.http.HttpResponse.BodySubscriber<T> downstream)
      Creates an AsyncBodyDecoder in sync mode.
      AsyncBodyDecoder​(AsyncDecoder decoder, java.net.http.HttpResponse.BodySubscriber<T> downstream, java.util.concurrent.Executor executor)
      Creates an AsyncBodyDecoder that 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 an AsyncBodyDecoder that supplies downstream items in the given executor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AsyncDecoder asyncDecoder()
      Returns the underlying AsyncDecoder.
      java.net.http.HttpResponse.BodySubscriber<T> downstream()
      Returns this decoder's downstream.
      java.lang.String encoding()
      Returns the encoding used by this decoder.
      java.util.Optional<java.util.concurrent.Executor> executor()
      Returns this decoder's executor if one is specified.
      void onComplete()  
      void onError​(java.lang.Throwable throwable)  
      void onNext​(java.util.List<java.nio.ByteBuffer> buffers)  
      void onSubscribe​(java.util.concurrent.Flow.Subscription upstreamSubscription)  
      • Methods inherited from class java.lang.Object

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

      • AsyncBodyDecoder

        public AsyncBodyDecoder​(AsyncDecoder decoder,
                                java.net.http.HttpResponse.BodySubscriber<T> downstream)
        Creates an AsyncBodyDecoder in sync mode.
      • AsyncBodyDecoder

        public AsyncBodyDecoder​(AsyncDecoder decoder,
                                java.net.http.HttpResponse.BodySubscriber<T> downstream,
                                java.util.concurrent.Executor executor)
        Creates an AsyncBodyDecoder that 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 an AsyncBodyDecoder that supplies downstream items in the given executor.
    • Method Detail

      • asyncDecoder

        public AsyncDecoder asyncDecoder()
        Returns the underlying AsyncDecoder.
      • encoding

        public java.lang.String encoding()
        Description copied from interface: BodyDecoder
        Returns the encoding used by this decoder. This corresponds to the value of the Content-Type header.
        Specified by:
        encoding in interface BodyDecoder<T>
      • executor

        public java.util.Optional<java.util.concurrent.Executor> executor()
        Description copied from interface: BodyDecoder
        Returns this decoder's executor if one is specified.
        Specified by:
        executor in interface BodyDecoder<T>
      • downstream

        public java.net.http.HttpResponse.BodySubscriber<T> downstream()
        Description copied from interface: BodyDecoder
        Returns this decoder's downstream.
        Specified by:
        downstream in interface BodyDecoder<T>
      • onSubscribe

        public void onSubscribe​(java.util.concurrent.Flow.Subscription upstreamSubscription)
        Specified by:
        onSubscribe in interface java.util.concurrent.Flow.Subscriber<T>
      • onNext

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

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

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