/** * Sets the timeout until a connection is etablished. A value of zero * means the timeout is not used. The default value is zero. * * @see HttpConnection#setConnectionTimeout(int) * @param newTimeoutInMilliseconds Timeout in milliseconds. * * @deprecated Use * {@link org.apache.commons.httpclient.params.HttpConnectionManagerParams#setConnectionTimeout(int)}, * {@link HttpConnectionManager#getParams()}. */ public synchronized void setConnectionTimeout(int newTimeoutInMilliseconds) { this.httpConnectionManager.getParams().setConnectionTimeout(newTimeoutInMilliseconds); }
@Override public HttpClient create() throws Exception { HttpClient client = new HttpClient(); if (soTimeout >= 0) { client.getParams().setSoTimeout(soTimeout); } if (connTimeout >= 0) { client.getHttpConnectionManager().getParams().setConnectionTimeout(connTimeout); } return client; }
/** * Uses the post method to send a url with arguments by http, this method can call RESTful Api. * * @param url the http url * @param timeout milliseconds to wait for the server to respond before giving up * @param processInputStream the response body stream processor */ public static void post(String url, Integer timeout, IProcessInputStream processInputStream) throws IOException { Preconditions.checkNotNull(timeout, "timeout"); Preconditions.checkNotNull(processInputStream, "processInputStream"); PostMethod postMethod = new PostMethod(url); try { HttpClient httpClient = new HttpClient(); httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(timeout); httpClient.getHttpConnectionManager().getParams().setSoTimeout(timeout); int statusCode = httpClient.executeMethod(postMethod); if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { InputStream inputStream = postMethod.getResponseBodyAsStream(); processInputStream.process(inputStream); } else { throw new IOException("Failed to perform POST request. Status code: " + statusCode); } } finally { postMethod.releaseConnection(); } }
LOGGER.info("Injecting configuration and resource managers to the API context"); final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setConnectionTimeout(_config.getServerAdminRequestTimeoutSeconds() * 1000);
connectionParams.setConnectionTimeout((int) settings.getHttpTimeout());
@Override public void setConnectTimeout(int connectTimeout) { connectionManager.getParams().setConnectionTimeout(connectTimeout * 1000); }
@Override public void setConnectTimeout(int connectTimeout) { connectionManager.getParams().setConnectionTimeout(connectTimeout * 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 MetalinkTemplateDownloader(StorageLayer storageLayer, String downloadUrl, String toDir, DownloadCompleteCallback callback, long maxTemplateSize) { super(storageLayer, downloadUrl, toDir, maxTemplateSize, callback); s_httpClientManager.getParams().setConnectionTimeout(5000); client = new HttpClient(s_httpClientManager); myretryhandler = createRetryTwiceHandler(); request = createRequest(downloadUrl); }
public HttpDirectTemplateDownloader(String url, Long templateId, String destPoolPath, String checksum, Map<String, String> headers) { super(url, destPoolPath, templateId, checksum); s_httpClientManager.getParams().setConnectionTimeout(5000); s_httpClientManager.getParams().setSoTimeout(5000); client = new HttpClient(s_httpClientManager); request = createRequest(url, headers); String downloadDir = getDirectDownloadTempPath(templateId); createTemporaryDirectoryAndFile(downloadDir); }
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(); }
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(); }
private void resolveHttpParams(HttpParams params) { if (params != null) { if (params.getProxy() != null) { InetSocketAddress socketAddress = (InetSocketAddress) params .getProxy().address(); httpClient.getHostConfiguration().setProxy( socketAddress.getHostName(), socketAddress.getPort()); } if (params.getSSLContext() != null) { Protocol.registerProtocol("https", new Protocol("https", new SSLProtocolSocketFactory(params.getSSLContext()), 443)); } httpClient.getHttpConnectionManager().getParams() .setConnectionTimeout(params.getConnectTimeout()); } }
/** * @param connectionTimeoutMS the connectionTimeoutMS to set */ public void setConnectionTimeoutMS(int connectionTimeoutMS) { connectionManager.getParams().setConnectionTimeout(connectionTimeoutMS); }
/** * @param connectionTimeoutMS the connectionTimeoutMS to set */ public void setConnectionTimeoutMS(int connectionTimeoutMS) { connectionManager.getParams().setConnectionTimeout(connectionTimeoutMS); }
/** * @param connectionTimeoutMS the connectionTimeoutMS to set */ public void setConnectionTimeoutMS(int connectionTimeoutMS) { connectionManager.getParams().setConnectionTimeout(connectionTimeoutMS); }
public JumpToCodeClient(Configuration configuration) { this.configuration = configuration; this.client = new HttpClient(); // client.getHttpConnectionManager().getParams().setConnectionTimeout(150); locationInfoCache = CacheBuilder.newBuilder().maximumSize(5000).expireAfterAccess(15, TimeUnit.MINUTES).build(); locationSourceCache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterAccess(15, TimeUnit.MINUTES).build(); ideCache = CacheBuilder.newBuilder().maximumSize(1).expireAfterWrite(10, TimeUnit.SECONDS).build(); }
/** * Sets the timeout until a connection is etablished. A value of 0 means <em>never</em> timeout. * * @param timeout the timeout value in milliseconds * @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setConnectionTimeout(int) */ public void setConnectionTimeout(int timeout) { if (timeout < 0) { throw new IllegalArgumentException("timeout must be a non-negative value"); } getHttpClient().getHttpConnectionManager().getParams().setConnectionTimeout(timeout); }
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); } }
private void initHttpClient() { HostConfiguration hostConfiguration = new HostConfiguration(); SimpleHttpConnectionManager connectionManager = new SimpleHttpConnectionManager(); connectionManager.closeIdleConnections(5000L); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setStaleCheckingEnabled(diamondConfigure.isConnectionStaleCheckingEnabled()); params.setConnectionTimeout(diamondConfigure.getConnectionTimeout()); connectionManager.setParams(params); configHttpClient = new HttpClient(connectionManager); configHttpClient.setHostConfiguration(hostConfiguration); }