/** * 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(); } }
@Override public void setReadTimeout(int readTimeout) { connectionManager.getParams().setSoTimeout(readTimeout * 1000); }
@Override public void setReadTimeout(int readTimeout) { connectionManager.getParams().setSoTimeout(readTimeout * 1000); }
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(); }
/** * @param socketTimeoutMS the socketTimeoutMS to set */ public void setSocketTimeoutMS(int socketTimeoutMS) { connectionManager.getParams().setSoTimeout(socketTimeoutMS); } }
/** * @param socketTimeoutMS the socketTimeoutMS to set */ public void setSocketTimeoutMS(int socketTimeoutMS) { connectionManager.getParams().setSoTimeout(socketTimeoutMS); }
/** * @param socketTimeoutMS the socketTimeoutMS to set */ public void setSocketTimeoutMS(int socketTimeoutMS) { connectionManager.getParams().setSoTimeout(socketTimeoutMS); }
/** * @param socketTimeoutMS the socketTimeoutMS to set */ public void setSocketTimeoutMS(int socketTimeoutMS) { connectionManager.getParams().setSoTimeout(socketTimeoutMS); } }
/** * Sets soTimeout (read timeout) on the underlying * HttpConnectionManager. This is desirable for queries, but * probably not for indexing. * @param timeout Timeout in milliseconds **/ public void setSoTimeout(int timeout) { getConnectionManager().getParams().setSoTimeout(timeout); }
/** * Set the socket read timeout for the underlying HttpClient. A value of 0 means <em>never</em> timeout. * * @param timeout the timeout value in milliseconds * @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setSoTimeout(int) */ public void setReadTimeout(int timeout) { if (timeout < 0) { throw new IllegalArgumentException("timeout must be a non-negative value"); } getHttpClient().getHttpConnectionManager().getParams().setSoTimeout(timeout); }
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);
private void createClient() { final HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setConnectionTimeout(AbstractQuery.DEFAULT_TIMEOUT_MILLISECONDS); params.setSoTimeout(AbstractQuery.DEFAULT_TIMEOUT_MILLISECONDS); params.setDefaultMaxConnectionsPerHost(MAX_HOST_CONNECTIONS); params.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS); final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); this.httpClient = new HttpClient(connectionManager); configureCredentials(); }
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 getClient() { HttpConnectionManagerParams httpConnectionManagerParams = httpConnectionManager.getParams(); if (null == httpConnectionManagerParams) httpConnectionManagerParams = new HttpConnectionManagerParams(); ConfluenceHttpParameters confluenceHttpParameters = settingsManager.getGlobalSettings().getConfluenceHttpParameters(); httpConnectionManagerParams.setConnectionTimeout(confluenceHttpParameters.getConnectionTimeout()); httpConnectionManagerParams.setSoTimeout(confluenceHttpParameters.getSocketTimeout()); return new HttpClient(httpConnectionManager); } }
protected synchronized HttpClient initialValue() { HttpClientParams params = new HttpClientParams(); params.setParameter(HttpClientParams.RETRY_HANDLER, noRetryHandler); IPHttpConnectionManager manager = new IPHttpConnectionManager(); Protocol dnsTimedProtocol = new Protocol("http", new DNSTimingProtocolSocketFactory(), 80); Protocol.registerProtocol("http", dnsTimedProtocol); manager.getParams().setConnectionTimeout(connectionTimeoutMS); manager.getParams().setSoTimeout(socketTimeoutMS); return new HttpClient(params, manager); } };
protected synchronized HttpClient initialValue() { HttpClientParams params = new HttpClientParams(); params.setParameter(HttpClientParams.RETRY_HANDLER, noRetryHandler); IPHttpConnectionManager manager = new IPHttpConnectionManager(); Protocol dnsTimedProtocol = new Protocol("http", new DNSTimingProtocolSocketFactory(), 80); Protocol.registerProtocol("http", dnsTimedProtocol); manager.getParams().setConnectionTimeout(connectionTimeoutMS); manager.getParams().setSoTimeout(socketTimeoutMS); return new HttpClient(params, manager); } };
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(); }
protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException { config = (XmlRpcHttpClientConfig) pRequest.getConfig(); method = newPostMethod(config); super.initHttpHeaders(pRequest); if (config.getConnectionTimeout() != 0) client.getHttpConnectionManager().getParams().setConnectionTimeout(config.getConnectionTimeout()); if (config.getReplyTimeout() != 0) client.getHttpConnectionManager().getParams().setSoTimeout(config.getReplyTimeout()); method.getParams().setVersion(HttpVersion.HTTP_1_1); }