@Test public void testMultiGet() { MultiGetRequest mget = new MultiGetRequest(Executors.newCachedThreadPool(), new MultiThreadedHttpConnectionManager()); List<String> urls = Arrays.asList("http://localhost:" + String.valueOf(portStart) + URI_PATH, "http://localhost:" + String.valueOf(portStart + 1) + URI_PATH,
final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setConnectionTimeout(_config.getServerAdminRequestTimeoutSeconds() * 1000);
/** * Return HttpClient with connection timeout */ private static HttpClient getHttpClient() { MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager(); s_httpClientManager.getParams().setConnectionTimeout(5000); return new HttpClient(s_httpClientManager); }
public HttpComponent3Factory() { httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); httpClient.getParams().setHttpElementCharset(Consts.UTF_8.name()); httpClient.getParams().setParameter("http.protocol.uri-charset", Consts.UTF_8.name()); // httpMethod.getParams().setUriCharset(Consts.UTF_8.name()); httpClient.getParams().setContentCharset(Consts.UTF_8.name()); Protocol.registerProtocol("https", new Protocol("https", new SSLProtocolSocketFactory( HttpClientFactory.allowSSLContext()), 443)); }
public static InputStream getInputStreamFromUrl(String url, String user, String password) { try { Pair<String, Integer> hostAndPort = validateUrl(url); HttpClient httpclient = new HttpClient(new MultiThreadedHttpConnectionManager()); if ((user != null) && (password != null)) { httpclient.getParams().setAuthenticationPreemptive(true); Credentials defaultcreds = new UsernamePasswordCredentials(user, password); httpclient.getState().setCredentials(new AuthScope(hostAndPort.first(), hostAndPort.second(), AuthScope.ANY_REALM), defaultcreds); s_logger.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second()); } // Execute the method. GetMethod method = new GetMethod(url); int statusCode = httpclient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { s_logger.error("Failed to read from URL: " + url); return null; } return method.getResponseBodyAsStream(); } catch (Exception ex) { s_logger.error("Failed to read from URL: " + url); return null; } }
public MultithreadedHttpClient() { connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setSoTimeout(30000); params.setConnectionTimeout(30000); params.setMaxTotalConnections(6); params.setDefaultMaxConnectionsPerHost(6); connectionManager.setParams(params); client = new HttpClient(connectionManager); applySystemProxySettings(); }
private HttpClient getHttpClient() { if (s_client == null) { final MultiThreadedHttpConnectionManager mgr = new MultiThreadedHttpConnectionManager(); mgr.getParams().setDefaultMaxConnectionsPerHost(4); // TODO make it configurable mgr.getParams().setMaxTotalConnections(1000); s_client = new HttpClient(mgr); final HttpClientParams clientParams = new HttpClientParams(); clientParams.setSoTimeout(ClusterServiceAdapter.ClusterMessageTimeOut.value() * 1000); s_client.setParams(clientParams); } return s_client; }
public MultithreadedHttpClient() { connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setSoTimeout(30000); params.setConnectionTimeout(30000); params.setMaxTotalConnections(6); params.setDefaultMaxConnectionsPerHost(6); connectionManager.setParams(params); client = createHttpClient(); applySystemProxySettings(); }
public MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager(){ if(multiThreadedHttpConnectionManager == null) this.multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager(); return multiThreadedHttpConnectionManager; }
static MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); // HttpClient instance that can be shared across threads and create multiple connections static HttpClient client = new HttpClient(connectionManager); // ... and when it's time to close connections connectionManager.shutdown();
/** * Creates the <tt>HttpClient</tt> that will be used by this WebConnection. Extensions may * override this method in order to create a customized <tt>HttpClient</tt> instance (e.g. with * a custom {@link org.apache.commons.httpclient.HttpConnectionManager} to perform some tracking; * see feature request 1438216). * @return the <tt>HttpClient</tt> that will be used by this WebConnection */ protected HttpClient createHttpClient() { final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); return new HttpClient(connectionManager); }
/** * */ public ARCUnwrappingProxy() { connectionManager = new MultiThreadedHttpConnectionManager(); hostConfiguration = new HostConfiguration(); }
MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); HttpClient httpClient = new HttpClient(connectionManager); // Only needed if you have a authentication Credentials credentials = new UsernamePasswordCredentials(username, password); httpClient.getState().setCredentials(AuthScope.ANY, credentials); httpClient.getParams().setAuthenticationPreemptive(true); clientExecutor = new ApacheHttpClientExecutor(httpClient); MyClass client = ProxyFactory.create(MyClass.class, "http://localhost:8080", clientExecutor);
ClientCollection(final String href, final AuthStrategy authStrategy) throws ProponoException { super("Standalone connection", "text", href); this.authStrategy = authStrategy; try { httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); // TODO: make connection timeout configurable httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000); } catch (final Throwable t) { throw new ProponoException("ERROR creating HTTPClient", t); } }
/** * Sets <code>HTTPConnectionManagerSettings</code>. * * @param connectionManagerSettings The connection manager settings. */ public void setConnectionManagerSettings(HTTPConnectionManagerSettings connectionManagerSettings) { this.connectionManagerSettings = connectionManagerSettings; initHttpConnectionManagerParams(connectionManagerSettings); connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(connectionParams); }
static private synchronized void kill() { for (HTTPSession session : sessionList) { session.close(); } sessionList.clear(); // Rebuild the connection manager connmgr.shutdown(); connmgr = new MultiThreadedHttpConnectionManager(); setThreadCount(DFALTTHREADCOUNT); } ////////////////////////////////////////////////////////////////////////
/** * */ public Http11BlockLoader() { connectionManager = new MultiThreadedHttpConnectionManager(); hostConfiguration = new HostConfiguration(); HttpClientParams params = new HttpClientParams(); // params.setParameter(HttpClientParams.RETRY_HANDLER, new NoRetryHandler()); http = new HttpClient(params,connectionManager); http.setHostConfiguration(hostConfiguration); }
/** * */ public ArcRemoteLiveWebCache() { connectionManager = new MultiThreadedHttpConnectionManager(); hostConfiguration = new HostConfiguration(); HttpClientParams params = new HttpClientParams(); params.setParameter(HttpClientParams.RETRY_HANDLER, new NoRetryHandler()); http = new HttpClient(params,connectionManager); http.setHostConfiguration(hostConfiguration); }
public BitlyUrlShortenerImpl() { httpClient = new HttpClient(); httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager()); HostConfiguration hostConfiguration = new HostConfiguration(); hostConfiguration.setHost("api-ssl.bitly.com", 443, Protocol.getProtocol("https")); httpClient.setHostConfiguration(hostConfiguration); }
/** Constructor. */ public RasterLayerComponentImpl() { getConstraint().setAlignmentX(LayoutConstraint.JUSTIFIED); getConstraint().setAlignmentY(LayoutConstraint.JUSTIFIED); MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager(); manager.setMaxConnectionsPerHost(10); httpClient = new HttpClient(manager); }