List of usage examples for org.apache.commons.httpclient.params HttpConnectionParams TCP_NODELAY
String TCP_NODELAY
To view the source code for org.apache.commons.httpclient.params HttpConnectionParams TCP_NODELAY.
Click Source Link
From source file:com.orange.mmp.net.http.HttpConnectionManager.java
public Connection getConnection() throws MMPNetException { SimpleHttpConnectionManager shcm = new SimpleHttpConnectionManager(); HttpClientParams defaultHttpParams = new HttpClientParams(); defaultHttpParams.setParameter(HttpMethodParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); defaultHttpParams.setParameter(HttpConnectionParams.TCP_NODELAY, true); defaultHttpParams.setParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false); defaultHttpParams.setParameter(HttpConnectionParams.SO_LINGER, 0); defaultHttpParams.setParameter(HttpClientParams.MAX_REDIRECTS, 3); defaultHttpParams.setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, false); HttpClient httpClient2 = new HttpClient(defaultHttpParams, shcm); if (HttpConnectionManager.proxyHost != null) { defaultHttpParams.setParameter("http.route.default-proxy", new HttpHost(HttpConnectionManager.proxyHost, HttpConnectionManager.proxyPort)); // TODO Host configuration ! if (HttpConnectionManager.proxyHost != null/* && this.useProxy*/) { HostConfiguration config = new HostConfiguration(); config.setProxy(HttpConnectionManager.proxyHost, HttpConnectionManager.proxyPort); httpClient2.setHostConfiguration(config); } else {/*from w ww .j a va 2 s . com*/ HostConfiguration config = new HostConfiguration(); config.setProxyHost(null); httpClient2.setHostConfiguration(config); } } return new HttpConnection(httpClient2); }
From source file:com.legstar.http.client.CicsHttp.java
/** * Create a reusable HTTP Client with a set of parameters that match * the remote CICS Server characteristics. At this stage, the HTTPClient is not * associated with a state and a method yet. * @param cicsHttpEndpoint the connection configuration * @return the new HTTP Client//from ww w . j av a 2s . c om */ protected HttpClient createHttpClient(final CicsHttpEndpoint cicsHttpEndpoint) { if (_log.isDebugEnabled()) { _log.debug("enter createHttpClient()"); } HttpClientParams params = new HttpClientParams(); /* Consider that if server is failing to respond, we should never retry. * A system such as CICS should always be responsive unless something * bad is happening in which case, retry makes things worse. */ DefaultHttpMethodRetryHandler retryhandler = new DefaultHttpMethodRetryHandler(0, false); params.setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler); /* Preemptive authentication forces the first HTTP payload to hold * credentials. This bypasses the inefficient default mechanism that * expects a 401 reply on the first request and then re-issues the same * request again with credentials.*/ params.setAuthenticationPreemptive(true); /* Set the receive time out. */ params.setSoTimeout(cicsHttpEndpoint.getReceiveTimeout()); /* Tell the connection manager how long we are prepared to wait * for a connection. */ params.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, cicsHttpEndpoint.getConnectTimeout()); /* Disable Nagle algorithm */ params.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true); HttpClient httpClient = new HttpClient(params); httpClient.setHostConfiguration(createHostConfiguration(cicsHttpEndpoint)); return httpClient; }
From source file:org.alfresco.httpclient.HttpClientFactory.java
protected HttpClient constructHttpClient() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); HttpClient httpClient = new HttpClient(connectionManager); HttpClientParams params = httpClient.getParams(); params.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true); params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, true); if (socketTimeout != null) { params.setSoTimeout(socketTimeout); }//ww w .ja v a 2 s. c o m HttpConnectionManagerParams connectionManagerParams = httpClient.getHttpConnectionManager().getParams(); connectionManagerParams.setMaxTotalConnections(maxTotalConnections); connectionManagerParams.setDefaultMaxConnectionsPerHost(maxHostConnections); connectionManagerParams.setConnectionTimeout(connectionTimeout); return httpClient; }
From source file:org.apache.abdera.protocol.client.AbderaClient.java
/** * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm tries to conserve bandwidth by * minimizing the number of segments that are sent. When applications wish to decrease network latency and increase * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data will be sent earlier, at the * cost of an increase in bandwidth consumption. *//*from w ww . j av a 2 s.co m*/ public void setTcpNoDelay(boolean enable) { client.getHttpConnectionManager().getParams().setBooleanParameter(HttpConnectionParams.TCP_NODELAY, enable); }
From source file:org.apache.abdera.protocol.client.AbderaClient.java
/** * Tests if Nagle's algorithm is to be used. *//* w w w. j a v a 2s. c o m*/ public boolean getTcpNoDelay() { return client.getHttpConnectionManager().getParams().getBooleanParameter(HttpConnectionParams.TCP_NODELAY, false); }
From source file:org.zaizi.alfresco.redlink.service.search.solr.SensefySolrQueryHTTPClient.java
public void init() { PropertyCheck.mandatory(this, "NodeService", nodeService); PropertyCheck.mandatory(this, "PermissionService", permissionService); PropertyCheck.mandatory(this, "RepositoryState", repositoryState); MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); httpClient = new HttpClient(connectionManager); HttpClientParams params = httpClient.getParams(); params.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true); params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, true); params.setSoTimeout(socketTimeout);// ww w . j a va 2s .c o m HttpConnectionManagerParams connectionManagerParams = httpClient.getHttpConnectionManager().getParams(); connectionManagerParams.setMaxTotalConnections(maxTotalConnections); connectionManagerParams.setDefaultMaxConnectionsPerHost(maxHostConnections); httpClient.getHostConfiguration().setHost(host, port); }