org.apache.http.nio.entity.ContentBufferEntity Java Examples
The following examples show how to use
org.apache.http.nio.entity.ContentBufferEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractResponseConsumer.java From fc-java-sdk with MIT License | 5 votes |
protected void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws IOException { long len = entity.getContentLength(); if (len > 2147483647L) { throw new ContentTooLongException("Entity content is too long: " + len); } else { if (len < 0L) { len = 4096L; } this.buf = new SimpleInputBuffer((int)len, new HeapByteBufferAllocator()); this.httpResponse.setEntity(new ContentBufferEntity(entity, this.buf)); } }
Example #2
Source File: ResponseConsumer.java From aliyun-tablestore-java-sdk with Apache License 2.0 | 5 votes |
@Override protected void onEntityEnclosed(final HttpEntity entity, final ContentType contentType) throws IOException { long len = entity.getContentLength(); if (len > Integer.MAX_VALUE) { throw new ContentTooLongException("Entity content is too long: " + len); } if (len < 0) { len = BUFFER_SIZE; } this.buf = new SimpleInputBuffer((int) len, new HeapByteBufferAllocator()); this.httpResponse.setEntity(new ContentBufferEntity(entity, this.buf)); }
Example #3
Source File: PoolingAsyncResponseConsumer.java From log4j2-elasticsearch with Apache License 2.0 | 4 votes |
/** * Writes content of given {@code org.apache.http.HttpEntity} to pooled buffer * * @param entity response entity * @param contentType content type of given entity * @throws IOException */ @Override protected void onEntityEnclosed( final HttpEntity entity, final ContentType contentType) throws IOException { // TODO: add entity.getContentLength() to metrics if (buffer == null) { buffer = getPooled(); // SimpleInputBuffer passed just to satisfy the constructor ContentBufferEntity bufferedEntity = new ContentBufferEntity(entity, buffer.getSource()); // override the content here (see ContentBufferEntity constructor) bufferedEntity.setContent(new ItemSourceContentInputStream(buffer)); this.response.setEntity(bufferedEntity); } }