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 ofAsyncResponseConsumer. 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 HeapBufferedAsyncResponseConsumer(int bufferLimit)Creates a new instance of this consumer with the provided buffer limit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.intgetBufferLimit()Get 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.
-
-
-
Constructor Detail
-
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:
java.lang.IllegalArgumentException- ifbufferLimitis less than or equal to 0.
-
-
Method Detail
-
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, java.io.IOExceptionTriggered 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.HttpExceptionjava.io.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:
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.
-
-