Search in sources :

Example 1 with SimpleInputBuffer

use of org.apache.http.nio.util.SimpleInputBuffer in project elasticsearch by elastic.

the class HeapBufferedAsyncResponseConsumer method onEntityEnclosed.

@Override
protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException {
    long len = entity.getContentLength();
    if (len > bufferLimitBytes) {
        throw new ContentTooLongException("entity content is too long [" + len + "] for the configured buffer limit [" + bufferLimitBytes + "]");
    }
    if (len < 0) {
        len = 4096;
    }
    this.buf = new SimpleInputBuffer((int) len, getByteBufferAllocator());
    this.response.setEntity(new ContentBufferEntity(entity, this.buf));
}
Also used : SimpleInputBuffer(org.apache.http.nio.util.SimpleInputBuffer) ContentTooLongException(org.apache.http.ContentTooLongException) ContentBufferEntity(org.apache.http.nio.entity.ContentBufferEntity)

Aggregations

ContentTooLongException (org.apache.http.ContentTooLongException)1 ContentBufferEntity (org.apache.http.nio.entity.ContentBufferEntity)1 SimpleInputBuffer (org.apache.http.nio.util.SimpleInputBuffer)1