List of usage examples for org.apache.commons.httpclient.params HttpConnectionManagerParams HttpConnectionManagerParams
HttpConnectionManagerParams
From source file:io.sightly.tck.http.Client.java
private HttpConnectionManagerParams prepareDefaultClientParameters() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setSoTimeout(SO_TIMEOUT); params.setConnectionTimeout(CONNECTION_TIMEOUT); return params; }
From source file:com.silverpeas.openoffice.windows.webdav.WebdavManager.java
/** * Prepare HTTP connections to the WebDav server * * @param host the webdav server host name. * @param login the login for the user on the webdav server. * @param password the login for the user on the webdav server. *//*from ww w.j ava 2s . com*/ public WebdavManager(String host, String login, String password) { HostConfiguration hostConfig = new HostConfiguration(); hostConfig.setHost(host); HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams connectionParams = new HttpConnectionManagerParams(); int maxHostConnections = 20; connectionParams.setMaxConnectionsPerHost(hostConfig, maxHostConnections); connectionManager.setParams(connectionParams); HttpClientParams clientParams = new HttpClientParams(); clientParams.setParameter(HttpClientParams.CREDENTIAL_CHARSET, "UTF-8"); clientParams.setParameter(HttpClientParams.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); client = new HttpClient(clientParams, connectionManager); Credentials creds = new UsernamePasswordCredentials(login, password); client.getState().setCredentials(AuthScope.ANY, creds); client.setHostConfiguration(hostConfig); }
From source file:com.clarkparsia.sbol.editor.sparql.StardogEndpoint.java
public StardogEndpoint(String url, String username, String passwd) { this.url = url; HttpConnectionManager manager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(20); params.setStaleCheckingEnabled(false); manager.setParams(params);//from w w w.ja v a2 s .c om HttpClientParams clientParams = new HttpClientParams(); client = new HttpClient(clientParams, manager); setCredentials(username, passwd); }
From source file:com.gisgraphy.fulltext.FullTextSearchEngine.java
/** * @param multiThreadedHttpConnectionManager * The/*from w w w. j a v a2 s. c om*/ * @link {@link MultiThreadedHttpConnectionManager} that the fulltext search * engine will use * @throws FullTextSearchException * If an error occured */ @Autowired public FullTextSearchEngine( @Qualifier("multiThreadedHttpConnectionManager") MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager) throws FullTextSearchException { Assert.notNull(multiThreadedHttpConnectionManager, "multiThreadedHttpConnectionManager can not be null"); HttpConnectionManagerParams p = new HttpConnectionManagerParams(); p.setSoTimeout(0); p.setConnectionTimeout(0); multiThreadedHttpConnectionManager.setParams(p); this.httpClient = new HttpClient(multiThreadedHttpConnectionManager); if (this.httpClient == null) { throw new FullTextSearchException( "Can not instanciate http client with multiThreadedHttpConnectionManager : " + multiThreadedHttpConnectionManager); } }
From source file:it.geosolutions.httpproxy.HTTPProxy.java
/** * Initialize the <code>ProxyServlet</code> * //from w ww . j a v a 2 s . co m * @param servletConfig The Servlet configuration passed in by the servlet conatiner */ public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); ServletContext context = getServletContext(); String proxyPropPath = context.getInitParameter("proxyPropPath"); proxyConfig = new ProxyConfig(getServletContext(), proxyPropPath); connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setSoTimeout(proxyConfig.getSoTimeout()); params.setConnectionTimeout(proxyConfig.getConnectionTimeout()); params.setMaxTotalConnections(proxyConfig.getMaxTotalConnections()); params.setDefaultMaxConnectionsPerHost(proxyConfig.getDefaultMaxConnectionsPerHost()); //setSystemProxy(params); connectionManager.setParams(params); httpClient = new HttpClient(connectionManager); // // Check for system proxy usage // try { String proxyHost = System.getProperty("http.proxyHost"); int proxyPort = 80; if (proxyHost != null && !proxyHost.isEmpty()) { try { proxyPort = (System.getProperty("http.proxyPort") != null ? Integer.parseInt(System.getProperty("http.proxyPort")) : proxyPort); httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort); } catch (Exception ex) { LOGGER.warning("No proxy port found"); } } } catch (Exception ex) { LOGGER.warning("Exception while setting the system proxy: " + ex.getLocalizedMessage()); } // ////////////////////////////////////////// // Setup the callbacks (in the future this // will be a pluggable lookup). // ////////////////////////////////////////// callbacks = new ArrayList<ProxyCallback>(); callbacks.add(new MimeTypeChecker(proxyConfig)); callbacks.add(new HostNameChecker(proxyConfig)); callbacks.add(new RequestTypeChecker(proxyConfig)); callbacks.add(new MethodsChecker(proxyConfig)); callbacks.add(new HostChecker(proxyConfig)); }
From source file:it.geosolutions.httpproxy.service.impl.ProxyServiceImpl.java
/** * Load proxy configuration when proxy config has changed *//* w w w . j a v a2s .c om*/ private void loadProxyConfig() { connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setSoTimeout(proxyConfig.getSoTimeout()); params.setConnectionTimeout(proxyConfig.getConnectionTimeout()); params.setMaxTotalConnections(proxyConfig.getMaxTotalConnections()); params.setDefaultMaxConnectionsPerHost(proxyConfig.getDefaultMaxConnectionsPerHost()); connectionManager.setParams(params); httpClient = new HttpClient(connectionManager); configureCallbacks(); }
From source file:com.twinsoft.convertigo.engine.util.HttpUtils.java
public static HttpClient makeHttpClient3(boolean usePool) { HttpClient httpClient;/*from w w w . j av a 2 s. com*/ if (usePool) { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); int maxTotalConnections = 100; try { maxTotalConnections = new Integer( EnginePropertiesManager.getProperty(PropertyName.HTTP_CLIENT_MAX_TOTAL_CONNECTIONS)) .intValue(); } catch (NumberFormatException e) { Engine.logEngine.warn("Unable to retrieve the max number of connections; defaults to 100."); } int maxConnectionsPerHost = 50; try { maxConnectionsPerHost = new Integer( EnginePropertiesManager.getProperty(PropertyName.HTTP_CLIENT_MAX_CONNECTIONS_PER_HOST)) .intValue(); } catch (NumberFormatException e) { Engine.logEngine .warn("Unable to retrieve the max number of connections per host; defaults to 100."); } HttpConnectionManagerParams httpConnectionManagerParams = new HttpConnectionManagerParams(); httpConnectionManagerParams.setDefaultMaxConnectionsPerHost(maxConnectionsPerHost); httpConnectionManagerParams.setMaxTotalConnections(maxTotalConnections); connectionManager.setParams(httpConnectionManagerParams); httpClient = new HttpClient(connectionManager); } else { httpClient = new HttpClient(); } HttpClientParams httpClientParams = (HttpClientParams) HttpClientParams.getDefaultParams(); httpClientParams.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); /** #741 : belambra wants only one Set-Cookie header */ httpClientParams.setParameter("http.protocol.single-cookie-header", Boolean.TRUE); /** #5066 : httpClient auto retries failed request up to 3 times by default */ httpClientParams.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false)); httpClient.setParams(httpClientParams); return httpClient; }
From source file:com.yahoo.flowetl.services.http.BaseHttpGenerator.java
/** * Gets the http connection manager params. * /* w w w . j av a 2 s. c om*/ * @return the manager params */ protected HttpConnectionManagerParams getManagerParams(HttpParams in) { HttpConnectionManagerParams out = new HttpConnectionManagerParams(); out.setConnectionTimeout(in.connectionTO); out.setSoTimeout(in.socketTO); out.setTcpNoDelay(true); return out; }
From source file:com.ms.commons.utilities.HttpClientUtils.java
public static synchronized void init() { if (connectionManager != null) { return;//from w ww. j a v a2 s .c o m } connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setConnectionTimeout(10000); params.setSoTimeout(20000); params.setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 1000); params.setMaxTotalConnections(10000); connectionManager.setParams(params); client = new HttpClient(connectionManager); client.getParams().setParameter("http.protocol.max-redirects", 3); }
From source file:com.taobao.diamond.client.impl.DefaultDiamondSubscriber.java
protected void initHttpClient() { if (MockServer.isTestMode()) { return;/*from w w w .j a va 2 s . com*/ } HostConfiguration hostConfiguration = new HostConfiguration(); hostConfiguration.setHost(diamondConfigure.getDomainNameList().get(this.domainNamePos.get()), diamondConfigure.getPort()); MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.closeIdleConnections(diamondConfigure.getPollingIntervalTime() * 4000); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setStaleCheckingEnabled(diamondConfigure.isConnectionStaleCheckingEnabled()); params.setMaxConnectionsPerHost(hostConfiguration, diamondConfigure.getMaxHostConnections()); params.setMaxTotalConnections(diamondConfigure.getMaxTotalConnections()); params.setConnectionTimeout(diamondConfigure.getConnectionTimeout()); // 1, // boyan@taobao.com params.setSoTimeout(60 * 1000); connectionManager.setParams(params); httpClient = new HttpClient(connectionManager); httpClient.setHostConfiguration(hostConfiguration); }