public DefaultHttpAsyncClient createClient(final AsyncHTTPConduit c) throws IOException {
if (connectionManager == null) {
setupNIOClient();
}
DefaultHttpAsyncClient dhac = new DefaultHttpAsyncClient(connectionManager) {
@Override
protected HttpParams createHttpParams() {
HttpParams params = new SyncBasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpConnectionParams.setTcpNoDelay(params, true);
int bufSize = c.getClient().getChunkLength() > 0 ? c.getClient().getChunkLength() : 16332;
HttpConnectionParams.setSocketBufferSize(params, bufSize);
HttpConnectionParams.setConnectionTimeout(params, (int)c.getClient().getConnectionTimeout());
return params;
}
@Override
protected BasicHttpProcessor createHttpProcessor() {
return httpproc;
}
};
//CXF handles redirects ourselves
dhac.setRedirectStrategy(new RedirectStrategy() {
public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context)
throws ProtocolException {
return false;
}
public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
throws ProtocolException {
return null;
}
});
dhac.setTargetAuthenticationStrategy(targetAuthenticationStrategy);
dhac.setProxyAuthenticationStrategy(proxyAuthenticationStrategy);
return dhac;
}