// Create protocol factory. Support HTTP/S only.
ProtocolFactory protocolFactory = new ProtocolFactory();
// Create and configure HTTP client
HttpParams params = new BasicHttpParams();
HttpProtocolParamBean hppb = new HttpProtocolParamBean(params);
HttpConnectionParamBean hcpb = new HttpConnectionParamBean(params);
ConnManagerParamBean cmpb = new ConnManagerParamBean(params);
// Set protocol parametes
hppb.setVersion(HttpVersion.HTTP_1_1);
hppb.setContentCharset(HTTP.ISO_8859_1);
hppb.setUseExpectContinue(true);
// Set connection parameters
hcpb.setStaleCheckingEnabled(false);
// Set connection manager parameters
ConnPerRouteBean connPerRouteBean = new ConnPerRouteBean();
connPerRouteBean.setDefaultMaxPerRoute(2);