Class HeapBufferedAsyncResponseConsumer

java.lang.Object
org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer<org.apache.hc.core5.http.ClassicHttpResponse,byte[]>
org.opensearch.client.transport.httpclient5.internal.HeapBufferedAsyncResponseConsumer
All Implemented Interfaces:
org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.AsyncResponseConsumer<org.apache.hc.core5.http.ClassicHttpResponse>, org.apache.hc.core5.http.nio.ResourceHolder

public class HeapBufferedAsyncResponseConsumer extends org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer<org.apache.hc.core5.http.ClassicHttpResponse,byte[]>
Default implementation of AsyncResponseConsumer. Buffers the whole response content in heap memory, meaning that the size of the buffer is equal to the content-length of the response. Limits the size of responses that can be read based on a configurable argument. Throws an exception in case the entity is longer than the configured buffer limit.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of this consumer with the provided buffer limit.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.hc.core5.http.ClassicHttpResponse
    buildResult(org.apache.hc.core5.http.HttpResponse response, byte[] entity, org.apache.hc.core5.http.ContentType contentType)
    Triggered to generate object that represents a result of response message processing.
    int
    Get the limit of the buffer.
    void
    informationResponse(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context)
    Triggered to signal receipt of an intermediate (1xx) HTTP response.

    Methods inherited from class org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer

    consume, consumeResponse, failed, releaseResources, streamEnd, updateCapacity

    Methods inherited from class java.lang.Object

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

    • HeapBufferedAsyncResponseConsumer

      public HeapBufferedAsyncResponseConsumer(int bufferLimit)
      Creates a new instance of this consumer with the provided buffer limit.
      Parameters:
      bufferLimit - the buffer limit. Must be greater than 0.
      Throws:
      IllegalArgumentException - if bufferLimit is less than or equal to 0.
  • Method Details

    • getBufferLimit

      public int getBufferLimit()
      Get the limit of the buffer.
    • informationResponse

      public void informationResponse(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context) throws org.apache.hc.core5.http.HttpException, IOException
      Triggered to signal receipt of an intermediate (1xx) HTTP response.
      Parameters:
      response - the intermediate (1xx) HTTP response.
      context - the actual execution context.
      Throws:
      org.apache.hc.core5.http.HttpException
      IOException
    • buildResult

      protected org.apache.hc.core5.http.ClassicHttpResponse buildResult(org.apache.hc.core5.http.HttpResponse response, byte[] entity, org.apache.hc.core5.http.ContentType contentType)
      Triggered to generate object that represents a result of response message processing.
      Specified by:
      buildResult in class org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer<org.apache.hc.core5.http.ClassicHttpResponse,byte[]>
      Parameters:
      response - the response message.
      entity - the response entity.
      contentType - the response content type.
      Returns:
      the result of response processing.