List of usage examples for org.apache.commons.httpclient.params HttpConnectionManagerParams getMaxConnectionsPerHost
public int getMaxConnectionsPerHost(HostConfiguration paramHostConfiguration)
From source file:com.liferay.portal.util.HttpImpl.java
public HostConfiguration getHostConfiguration(String location) throws IOException { if (_log.isDebugEnabled()) { _log.debug("Location is " + location); }// w w w. j a va 2 s . c o m HostConfiguration hostConfiguration = new HostConfiguration(); hostConfiguration.setHost(new URI(location, false)); if (isProxyHost(hostConfiguration.getHost())) { hostConfiguration.setProxy(_PROXY_HOST, _PROXY_PORT); } HttpConnectionManager httpConnectionManager = _httpClient.getHttpConnectionManager(); HttpConnectionManagerParams httpConnectionManagerParams = httpConnectionManager.getParams(); int defaultMaxConnectionsPerHost = httpConnectionManagerParams.getMaxConnectionsPerHost(hostConfiguration); int maxConnectionsPerHost = GetterUtil.getInteger(PropsUtil.get( HttpImpl.class.getName() + ".max.connections.per.host", new Filter(hostConfiguration.getHost()))); if ((maxConnectionsPerHost > 0) && (maxConnectionsPerHost != defaultMaxConnectionsPerHost)) { httpConnectionManagerParams.setMaxConnectionsPerHost(hostConfiguration, maxConnectionsPerHost); } int timeout = GetterUtil.getInteger( PropsUtil.get(HttpImpl.class.getName() + ".timeout", new Filter(hostConfiguration.getHost()))); if (timeout > 0) { HostParams hostParams = hostConfiguration.getParams(); hostParams.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, timeout); hostParams.setIntParameter(HttpConnectionParams.SO_TIMEOUT, timeout); } return hostConfiguration; }
From source file:org.eclipse.mylyn.commons.tests.net.WebUtilTest.java
public void testConfigureClient() throws Exception { WebLocation location = new WebLocation(TestUrl.DEFAULT.getHttpOk().toString()); WebUtil.createHostConfiguration(client, location, null /*monitor*/); HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams(); assertEquals(CoreUtil.TEST_MODE ? 2 : MAX_HTTP_HOST_CONNECTIONS_DEFAULT, params.getMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION)); assertEquals(CoreUtil.TEST_MODE ? 20 : MAX_HTTP_TOTAL_CONNECTIONS_DEFAULT, params.getMaxTotalConnections()); }