Class ReactiveResponseConsumer

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

@Contract(threading=SAFE) public final class ReactiveResponseConsumer extends Object implements org.apache.hc.core5.http.nio.AsyncResponseConsumer<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
    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<ByteBuffer>>> responseCallback)
    Creates a ReactiveResponseConsumer that will call back the supplied FutureCallback with a streamable response.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    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<Void> resultCallback)
     
    void
     
    org.apache.hc.core5.http.EntityDetails
    Returns the response entity details.
    org.apache.hc.core5.http.HttpResponse
    Returns the intermediate (1xx) HTTP response if one was received.
    Future<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse, org.reactivestreams.Publisher<ByteBuffer>>>
     
    List<org.apache.hc.core5.http.Header>
    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
     
    void
    streamEnd(List<? extends org.apache.hc.core5.http.Header> trailers)
     
    void
    updateCapacity(org.apache.hc.core5.http.nio.CapacityChannel capacityChannel)
     

    Methods inherited from class Object

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

    • 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<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 Details

    • getResponseFuture

      public Future<org.apache.hc.core5.http.Message<org.apache.hc.core5.http.HttpResponse, org.reactivestreams.Publisher<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 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<Void> resultCallback)
      Specified by:
      consumeResponse in interface org.apache.hc.core5.http.nio.AsyncResponseConsumer<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<Void>
    • failed

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

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

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

      public void streamEnd(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