use of org.apache.http.nio.util.HeapByteBufferAllocator in project fc-java-sdk by aliyun.
the class AbstractResponseConsumer method onEntityEnclosed.
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));
}
}
use of org.apache.http.nio.util.HeapByteBufferAllocator in project wso2-synapse by wso2.
the class SourceHandler method getOutputStream.
/**
* Create synapse.response-source-buffer for GET and HEAD Http methods
* @param method Http Method
* @param request Source Request
* @return OutputStream
*/
public OutputStream getOutputStream(String method, SourceRequest request) {
OutputStream os = null;
if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method)) {
HttpContext context = request.getConnection().getContext();
ContentOutputBuffer outputBuffer = new SimpleOutputBuffer(sourceConfiguration.getIOBufferSize(), new HeapByteBufferAllocator());
context.setAttribute("synapse.response-source-buffer", outputBuffer);
os = new ContentOutputStream(outputBuffer);
}
return os;
}
use of org.apache.http.nio.util.HeapByteBufferAllocator in project wso2-synapse by wso2.
the class BaseConfiguration method build.
public void build() throws AxisFault {
iOBufferSize = conf.getIOBufferSize();
if (workerPool == null) {
workerPool = WorkerPoolFactory.getWorkerPool(conf.getWorkerPoolCoreSize(), conf.getWorkerPoolMaxSize(), conf.getWorkerThreadKeepaliveSec(), conf.getWorkerPoolQueueLen(), PASSTHROUGH_THREAD_GROUP, PASSTHROUGH_THREAD_ID);
}
httpParams = buildHttpParams();
ioReactorConfig = buildIOReactorConfig();
String sysCorrelationStatus = System.getProperty(PassThroughConstants.CORRELATION_LOGS_SYS_PROPERTY);
if (sysCorrelationStatus != null) {
correlationLoggingEnabled = sysCorrelationStatus.equalsIgnoreCase("true");
}
bufferFactory = new BufferFactory(iOBufferSize, new HeapByteBufferAllocator(), 512);
}
Aggregations