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
ConstructorsConstructorDescriptionHeapBufferedAsyncResponseConsumer(int bufferLimit) Creates a new instance of this consumer with the provided buffer limit. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.hc.core5.http.ClassicHttpResponsebuildResult(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.intGet the limit of the buffer.voidinformationResponse(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
-
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- ifbufferLimitis 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.HttpExceptionIOException
-
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:
buildResultin classorg.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.
-