/** * Creates an instance of HttpClient using default {@link HttpClientParams parameter set}. * * @see HttpClientParams */ public HttpClient() { this(new HttpClientParams()); }
/** * Creates an instance of HttpClient with a user specified * {@link HttpConnectionManager HTTP connection manager}. * * @param httpConnectionManager The {@link HttpConnectionManager connection manager} * to use. * * @since 2.0 */ public HttpClient(HttpConnectionManager httpConnectionManager) { this(new HttpClientParams(), httpConnectionManager); }
/** * Creates an instance of ProxyClient using default {@link HttpClientParams parameter set}. * * @see HttpClientParams */ public ProxyClient() { this(new HttpClientParams()); }
/** * GET urls in parallel using the executor service. * @param urls absolute URLs to GET * @param timeoutMs timeout in milliseconds for each GET request * @return instance of CompletionService. Completion service will provide * results as they arrive. The order is NOT same as the order of URLs */ public CompletionService<GetMethod> execute(List<String> urls, int timeoutMs) { HttpClientParams clientParams = new HttpClientParams(); clientParams.setConnectionManagerTimeout(timeoutMs); HttpClient client = new HttpClient(clientParams, _connectionManager); CompletionService<GetMethod> completionService = new ExecutorCompletionService<>(_executor); for (String url : urls) { completionService.submit(() -> { try { GetMethod getMethod = new GetMethod(url); getMethod.getParams().setSoTimeout(timeoutMs); client.executeMethod(getMethod); return getMethod; } catch (Exception e) { // Log only exception type and message instead of the whole stack trace LOGGER.warn("Caught '{}' while executing GET on URL: {}", e.toString(), url); throw e; } }); } return completionService; } }
protected HttpParams createParams() { HttpClientParams params = new HttpClientParams(null);
pathPrefix = (StringUtils.hasText(pathPref) ? addLeadingSlashIfNeeded(StringUtils.trimWhitespace(pathPref)) : StringUtils.trimWhitespace(pathPref)); HttpClientParams params = new HttpClientParams(); params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler( settings.getHttpRetries(), false) {
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; }
private void init() { initList(m_ipList, ipFilePath); initList(m_uaList, uaFilePath); initList(m_itemList, itmFilePath); initList(m_tsList,tsFilePath); initList(m_siteList,siteFilePath); initList(m_dsList,dsFilePath); initGUIDList(); String finalURL = ""; if (batchMode) { finalURL = BATCH_URL; } else { finalURL = URL; } m_payload = readFromResource(); HttpClientParams clientParams = new HttpClientParams(); clientParams.setSoTimeout(60000); m_client = new HttpClient(clientParams); m_method = new PostMethod(NODE + finalURL + EVENTTYPE); m_method.setRequestHeader("Connection", "Keep-Alive"); m_method.setRequestHeader("Accept-Charset", "UTF-8"); }
/** * Creates an instance of ProxyClient using default {@link HttpClientParams parameter set}. * * @see HttpClientParams */ public ProxyClient() { this(new HttpClientParams()); }
/** * Creates an instance of HttpClient using default {@link HttpClientParams parameter set}. * * @see HttpClientParams */ public HttpClient() { this(new HttpClientParams()); }
/** * Creates an instance of HttpClient using default {@link HttpClientParams parameter set}. * * @see HttpClientParams */ public HttpClient() { this(new HttpClientParams()); }
/** * Creates an instance of HttpClient using default {@link HttpClientParams parameter set}. * * @see HttpClientParams */ public HttpClient() { this(new HttpClientParams()); }
/** * Creates an instance of ProxyClient using default {@link HttpClientParams parameter set}. * * @see HttpClientParams */ public ProxyClient() { this(new HttpClientParams()); }
/** * */ 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 ApacheHttp31SLRFactory() { connectionManager = new MultiThreadedHttpConnectionManager(); //connectionManager = new ThreadLocalHttpConnectionManager(); hostConfiguration = new HostConfiguration(); HttpClientParams params = new HttpClientParams(); http = new HttpClient(params,connectionManager); http.setHostConfiguration(hostConfiguration); }
private HttpClient createHttpClient(ResultBuilder builder, Map<String, Object> parameters) throws Exception { HttpClientParams clientParams = setProperties(new HttpClientParams(), "httpClient.", parameters); HttpClient client = new HttpClient(clientParams); CompositeHttpConfigurer configurer = new CompositeHttpConfigurer(); configureProxy(builder, parameters).ifPresent(configurer::addConfigurer); configureAuthentication(builder, parameters).ifPresent(configurer::addConfigurer); configurer.configureHttpClient(client); return client; } }
public HttpClientFeedFetcher(final FeedFetcherCache cache, final CredentialSupplier credentialSupplier) { setHttpClientParams(new HttpClientParams()); setFeedInfoCache(cache); setCredentialSupplier(credentialSupplier); }
HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams(); cmparams.setSoTimeout(10000); cmparams.setTcpNoDelay(true); HttpConnectionManager manager = new SimpleHttpConnectionManager(); manager.setParams(cmparams); params = new HttpClientParams(); params.setSoTimeout(5000); client = new HttpClient(params, manager);
/** * */ 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); }
HttpClient http = new HttpClient(); http.setParams(new HttpClientParams()); http.setState(new HttpState()); //For Get GetMethod get = new GetMethod("http://www.something.com/myscript?param="+paramVar); http.executeMethod(get); // For Post PostMethod post = new PostMethod("http://www.something.com/myscript"); post.addParameter("param", paramVar); http.executeMethod(post);