Class ReactiveResponseConsumer

  • All Implemented Interfaces:
    org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.AsyncResponseConsumer<java.lang.Void>, org.apache.hc.core5.http.nio.ResourceHolder

    @Contract(threading=SAFE)
    public final class ReactiveResponseConsumer
    extends java.lang.Object
    implements org.apache.hc.core5.http.nio.AsyncResponseConsumer<java.lang.Void>
    An AsyncResponseConsumer that publishes the response body through a Publisher, as defined by the Reactive Streams specification. The response is represented as a Message consisting of a HttpResponse representing the headers and a Publisher representing the response body as an asynchronous stream of ByteBuffer instances.
    Since:
    5.0
    • Constructor Summary

      Constructors 
      Constructor Description
      ReactiveResponseConsumer()
      Creates a ReactiveResponseConsumer.
      ReactiveResponseConsumer​(org.apache.hc.core5.concurrent.FutureCallback<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse,​org.reactivestreams.Publisher<java.nio.ByteBuffer>>> responseCallback)
      Creates a ReactiveResponseConsumer that will call back the supplied FutureCallback with a streamable response.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void consume​(java.nio.ByteBuffer src)  
      void consumeResponse​(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.EntityDetails entityDetails, org.apache.hc.core5.http.protocol.HttpContext httpContext, org.apache.hc.core5.concurrent.FutureCallback<java.lang.Void> resultCallback)  
      void failed​(java.lang.Exception cause)  
      org.apache.hc.core5.http.EntityDetails getEntityDetails()
      Returns the response entity details.
      org.apache.hc.core5.http.HttpResponse getInformationResponse()
      Returns the intermediate (1xx) HTTP response if one was received.
      java.util.concurrent.Future<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse,​org.reactivestreams.Publisher<java.nio.ByteBuffer>>> getResponseFuture()  
      java.util.List<org.apache.hc.core5.http.Header> getTrailers()
      Returns the trailers received at the end of the response.
      void informationResponse​(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext httpContext)  
      void releaseResources()  
      void streamEnd​(java.util.List<? extends org.apache.hc.core5.http.Header> trailers)  
      void updateCapacity​(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel)  
      • Methods inherited from class java.lang.Object

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

      • ReactiveResponseConsumer

        public ReactiveResponseConsumer()
        Creates a ReactiveResponseConsumer.
      • ReactiveResponseConsumer

        public ReactiveResponseConsumer​(org.apache.hc.core5.concurrent.FutureCallback<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse,​org.reactivestreams.Publisher<java.nio.ByteBuffer>>> responseCallback)
        Creates a ReactiveResponseConsumer that will call back the supplied FutureCallback with a streamable response.
        Parameters:
        responseCallback - the callback to invoke when the response is available for consumption.
    • Method Detail

      • getResponseFuture

        public java.util.concurrent.Future<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse,​org.reactivestreams.Publisher<java.nio.ByteBuffer>>> getResponseFuture()
      • getInformationResponse

        public org.apache.hc.core5.http.HttpResponse getInformationResponse()
        Returns the intermediate (1xx) HTTP response if one was received.
        Returns:
        the information response, or null if none.
      • getEntityDetails

        public org.apache.hc.core5.http.EntityDetails getEntityDetails()
        Returns the response entity details.
        Returns:
        the entity details, or null if none.
      • getTrailers

        public java.util.List<org.apache.hc.core5.http.Header> getTrailers()
        Returns the trailers received at the end of the response.
        Returns:
        a non-null list of zero or more trailers.
      • consumeResponse

        public void consumeResponse​(org.apache.hc.core5.http.HttpResponse response,
                                    org.apache.hc.core5.http.EntityDetails entityDetails,
                                    org.apache.hc.core5.http.protocol.HttpContext httpContext,
                                    org.apache.hc.core5.concurrent.FutureCallback<java.lang.Void> resultCallback)
        Specified by:
        consumeResponse in interface org.apache.hc.core5.http.nio.AsyncResponseConsumer<java.lang.Void>
      • informationResponse

        public void informationResponse​(org.apache.hc.core5.http.HttpResponse response,
                                        org.apache.hc.core5.http.protocol.HttpContext httpContext)
        Specified by:
        informationResponse in interface org.apache.hc.core5.http.nio.AsyncResponseConsumer<java.lang.Void>
      • failed

        public void failed​(java.lang.Exception cause)
        Specified by:
        failed in interface org.apache.hc.core5.http.nio.AsyncResponseConsumer<java.lang.Void>
      • updateCapacity

        public void updateCapacity​(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel)
                            throws java.io.IOException
        Specified by:
        updateCapacity in interface org.apache.hc.core5.http.nio.AsyncDataConsumer
        Throws:
        java.io.IOException
      • consume

        public void consume​(java.nio.ByteBuffer src)
                     throws java.io.IOException
        Specified by:
        consume in interface org.apache.hc.core5.http.nio.AsyncDataConsumer
        Throws:
        java.io.IOException
      • streamEnd

        public void streamEnd​(java.util.List<? extends org.apache.hc.core5.http.Header> trailers)
        Specified by:
        streamEnd in interface org.apache.hc.core5.http.nio.AsyncDataConsumer
      • releaseResources

        public void releaseResources()
        Specified by:
        releaseResources in interface org.apache.hc.core5.http.nio.ResourceHolder