List of usage examples for org.apache.commons.httpclient MultiThreadedHttpConnectionManager MultiThreadedHttpConnectionManager
public MultiThreadedHttpConnectionManager()
From source file:fr.unix_experience.owncloud_sms.engine.OCHttpClient.java
public OCHttpClient(Context context, Uri serverURI, String accountName, String accountPassword) { super(new MultiThreadedHttpConnectionManager()); Protocol easyhttps = new Protocol("https", (ProtocolSocketFactory) new EasySSLProtocolSocketFactory(), 443); Protocol.registerProtocol("https", easyhttps); _serverURI = serverURI;/*from w ww. j a va 2 s.co m*/ _username = accountName; _password = accountPassword; getParams().setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true); getParams().setParameter(PARAM_PROTOCOL_VERSION, HttpVersion.HTTP_1_1); getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); getParams().setParameter(HttpMethodParams.USER_AGENT, "nextcloud-phonesync (" + new AndroidVersionProvider(context).getVersionCode() + ")"); }
From source file:com.marvelution.hudson.plugins.apiv2.client.connectors.HttpClient3Connector.java
/** * Create the {@link HttpClient} object// ww w .jav a 2s. c o m */ private void createClient() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setConnectionTimeout(TIMEOUT_MS); params.setDefaultMaxConnectionsPerHost(MAX_HOST_CONNECTIONS); params.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS); MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); httpClient = new HttpClient(connectionManager); configureCredentials(); if (StringUtils.isNotBlank(System.getProperty("http.proxyHost"))) { log.debug("A HTTP Proxy is configured"); System.setProperty("java.net.useSystemProxies", "true"); Proxy proxy = chooseProxy(); if (proxy.type() == Type.HTTP && proxy.address() instanceof InetSocketAddress) { // convert the socket address to an ProxyHost final InetSocketAddress isa = (InetSocketAddress) proxy.address(); // assume default scheme (http) ProxyHost proxyHost = new ProxyHost(getHost(isa), isa.getPort()); httpClient.getHostConfiguration().setProxyHost(proxyHost); if (StringUtils.isNotBlank(System.getProperty("http.proxyUser"))) { String user = System.getProperty("http.proxyUser"); String password = System.getProperty("http.proxyPassword"); httpClient.getState().setProxyCredentials(new AuthScope(getHost(isa), isa.getPort()), new UsernamePasswordCredentials(user, password)); } } } }
From source file:fedora.localservices.saxon.SaxonServlet.java
/** * Initialize the servlet by setting up the stylesheet cache, the http * connection manager, and configuring credentials for the http client. *//* w w w. j a v a2s . co m*/ @Override public void init(ServletConfig config) throws ServletException { m_cache = new HashMap<String, Templates>(); m_creds = new HashMap<String, UsernamePasswordCredentials>(); m_cManager = new MultiThreadedHttpConnectionManager(); m_cManager.getParams().setConnectionTimeout(TIMEOUT_SECONDS * 1000); Enumeration<?> enm = config.getInitParameterNames(); while (enm.hasMoreElements()) { String name = (String) enm.nextElement(); if (name.startsWith(CRED_PARAM_START)) { String value = config.getInitParameter(name); if (value.indexOf(":") == -1) { throw new ServletException( "Malformed credentials for " + name + " -- expected ':' user/pass delimiter"); } String[] parts = value.split(":"); String user = parts[0]; StringBuffer pass = new StringBuffer(); for (int i = 1; i < parts.length; i++) { if (i > 1) { pass.append(':'); } pass.append(parts[i]); } m_creds.put(name.substring(CRED_PARAM_START.length()), new UsernamePasswordCredentials(user, pass.toString())); } } }
From source file:com.funambol.json.dao.AuthenticatorDAOImpl.java
public AuthenticatorDAOImpl() { try {/* ww w .j a v a 2 s. c om*/ //Get the connection parameters... this.serverUrl = JsonConnectorConfig.getConfigInstance().getJsonServerUrl(); } catch (JsonConfigException e) { log.trace("Error getting information from the configuration file.", e); } HttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager(); this.httpClient = new HttpClient(httpConnectionManager); }
From source file:net.sf.dsig.verify.OCSPHelper.java
private HttpConnectionManager getConnectionManager() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setSoTimeout(timeoutMillis); connectionManager.getParams().setConnectionTimeout(timeoutMillis); return connectionManager; }
From source file:cn.vlabs.umt.ui.servlet.OnlineStorageLoginServlet.java
private String getSid(HttpServletRequest request) { String uid = null;/*from w w w . j a v a 2 s . co m*/ ThirdPartyCredential tpc = (ThirdPartyCredential) request.getSession() .getAttribute(Attributes.THIRDPARTY_CREDENTIAL); if (tpc != null) { HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager()); String loginThirdpartyAppURL = request.getParameter("loginThirdpartyAppURL"); if (loginThirdpartyAppURL == null) { loginThirdpartyAppURL = "http://mail.cnic.cn/coremail/index.jsp"; } PostMethod method = new PostMethod(loginThirdpartyAppURL); method.setParameter("uid", tpc.getUsername()); method.setParameter("password", tpc.getPassword()); method.setParameter("action:login", ""); method.setParameter("face", "H"); try { client.executeMethod(method); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } finally { if (uid == null) { request.setAttribute("tip", "ssoLostPassword"); request.setAttribute(Attributes.RETURN_URL, request.getParameter(Attributes.RETURN_URL)); } } Header locationHeader = (Header) method.getResponseHeader("Location"); if (locationHeader != null) { String location = locationHeader.getValue(); uid = location.substring(location.lastIndexOf("?") + 5); } method.releaseConnection(); client.getHttpConnectionManager().closeIdleConnections(0); } else { request.setAttribute("tip", "onlyCstnetUserLoginOnlineStorage"); } return uid; }
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 w ww .j av a 2s .c o m*/ 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.gisgraphy.domain.geoloc.service.fulltextsearch.SolrClientTest.java
@Test public void testBindToURL() { IsolrClient clientAlive = new SolrClient("http://nowhere.tld/solr", new MultiThreadedHttpConnectionManager()); clientAlive.bindToUrl(AbstractIntegrationHttpSolrTestCase.fulltextSearchUrlBinded); try {/*from www . jav a 2 s . c o m*/ clientAlive.bindToUrl("http://nowhere.tld:4747solr"); fail("BindToUrl should throw for malformedUrl"); } catch (Exception e) { } }
From source file:com.sun.syndication.propono.atom.client.ClientAtomService.java
private Document getAtomServiceDocument() throws ProponoException { GetMethod method = null;//from w w w . j a v a 2s. c o m int code = -1; try { httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); // TODO: make connection timeout configurable httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000); method = new GetMethod(uri); authStrategy.addAuthentication(httpClient, method); httpClient.executeMethod(method); SAXBuilder builder = new SAXBuilder(); return builder.build(method.getResponseBodyAsStream()); } catch (Throwable t) { String msg = "ERROR retrieving Atom Service Document, code: " + code; logger.debug(msg, t); throw new ProponoException(msg, t); } finally { if (method != null) method.releaseConnection(); } }
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. j a v a2s . co m HttpClientParams clientParams = new HttpClientParams(); client = new HttpClient(clientParams, manager); setCredentials(username, passwd); }