org.apache.http.params.HttpConnectionParams Java Examples
The following examples show how to use
org.apache.http.params.HttpConnectionParams.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JiraClientFactoryImpl.java From jira-ext-plugin with Apache License 2.0 | 6 votes |
@Override public JiraClient newJiraClient() { Config.PluginDescriptor config = Config.getGlobalConfig(); String jiraUrl = config.getJiraBaseUrl(); String username = config.getUsername(); String password = Secret.toString(config.getPassword()); BasicCredentials creds = new BasicCredentials(username, password); JiraClient client = new JiraClient(jiraUrl, creds); DefaultHttpClient httpClient = (DefaultHttpClient)client.getRestClient().getHttpClient(); int timeoutInSeconds = config.getTimeout(); HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), timeoutInSeconds * 1000); HttpConnectionParams.setSoTimeout(httpClient.getParams(), timeoutInSeconds * 1000); return client; }
Example #2
Source File: ClientUtils.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
/** * * @param request * @param payload * @return */ protected HttpResponse sendRequest(HttpUriRequest request) { HttpResponse response = null; try { HttpClient httpclient = new DefaultHttpClient(); log(request); HttpParams params = httpclient.getParams(); HttpConnectionParams.setConnectionTimeout(params, timeout); HttpConnectionParams.setSoTimeout(params, timeout); if(proxy != null) { httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } response = httpclient.execute(request); } catch(IOException ioe) { throw new EFhirClientException("Error sending Http Request: "+ioe.getMessage(), ioe); } return response; }
Example #3
Source File: ClientUtils.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
/** * * @param request * @param payload * @return */ protected HttpResponse sendRequest(HttpUriRequest request) { HttpResponse response = null; try { HttpClient httpclient = new DefaultHttpClient(); log(request); HttpParams params = httpclient.getParams(); HttpConnectionParams.setConnectionTimeout(params, timeout); HttpConnectionParams.setSoTimeout(params, timeout); if(proxy != null) { httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } response = httpclient.execute(request); } catch(IOException ioe) { throw new EFhirClientException("Error sending Http Request: "+ioe.getMessage(), ioe); } return response; }
Example #4
Source File: RestClient.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private void init(String host, int port, String userName, String password) { this.host = host; this.port = port; this.userName = userName; this.password = password; this.baseUrl = SCHEME_HTTP + host + ":" + port + KYLIN_API_PATH; final HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(httpParams, httpSocketTimeoutMs); HttpConnectionParams.setConnectionTimeout(httpParams, httpConnectionTimeoutMs); final PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); KylinConfig config = KylinConfig.getInstanceFromEnv(); cm.setDefaultMaxPerRoute(config.getRestClientDefaultMaxPerRoute()); cm.setMaxTotal(config.getRestClientMaxTotal()); client = new DefaultHttpClient(cm, httpParams); if (userName != null && password != null) { CredentialsProvider provider = new BasicCredentialsProvider(); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(userName, password); provider.setCredentials(AuthScope.ANY, credentials); client.setCredentialsProvider(provider); } }
Example #5
Source File: RESTClient.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Sets up the client */ private void setup() { httpclient = new DefaultHttpClient(new ThreadSafeClientConnManager()); HttpParams params = httpclient.getParams(); HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SOCKET_TIMEOUT); httpclient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() { public boolean retryRequest(IOException e, int i, HttpContext httpContext) { return false; } }); }
Example #6
Source File: EasySSLSocketFactory.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/** * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket, * java.lang.String, int, java.net.InetAddress, int, * org.apache.http.params.HttpParams) */ @Override public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
Example #7
Source File: SOAPClient.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Sets up the client */ private void setup() { httpclient = new DefaultHttpClient(new ThreadSafeClientConnManager()); HttpParams params = httpclient.getParams(); HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SOCKET_TIMEOUT); httpclient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() { public boolean retryRequest(IOException e, int i, HttpContext httpContext) { return false; } }); }
Example #8
Source File: HttpClientStack.java From volley with Apache License 2.0 | 6 votes |
@Override public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, AuthFailureError { HttpUriRequest httpRequest = createHttpRequest(request, additionalHeaders); setHeaders(httpRequest, additionalHeaders); // Request.getHeaders() takes precedence over the given additional (cache) headers) and any // headers set by createHttpRequest (like the Content-Type header). setHeaders(httpRequest, request.getHeaders()); onPrepareRequest(httpRequest); HttpParams httpParams = httpRequest.getParams(); int timeoutMs = request.getTimeoutMs(); // TODO: Reevaluate this connection timeout based on more wide-scale // data collection and possibly different for wifi vs. 3G. HttpConnectionParams.setConnectionTimeout(httpParams, 5000); HttpConnectionParams.setSoTimeout(httpParams, timeoutMs); return mClient.execute(httpRequest); }
Example #9
Source File: MainActivity.java From android-advanced-light with MIT License | 6 votes |
/** * 设置默认请求参数,并返回HttpClient * * @return HttpClient */ private HttpClient createHttpClient() { HttpParams mDefaultHttpParams = new BasicHttpParams(); //设置连接超时 HttpConnectionParams.setConnectionTimeout(mDefaultHttpParams, 15000); //设置请求超时 HttpConnectionParams.setSoTimeout(mDefaultHttpParams, 15000); HttpConnectionParams.setTcpNoDelay(mDefaultHttpParams, true); HttpProtocolParams.setVersion(mDefaultHttpParams, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(mDefaultHttpParams, HTTP.UTF_8); //持续握手 HttpProtocolParams.setUseExpectContinue(mDefaultHttpParams, true); HttpClient mHttpClient = new DefaultHttpClient(mDefaultHttpParams); return mHttpClient; }
Example #10
Source File: WebServiceNtlmSender.java From iaf with Apache License 2.0 | 6 votes |
@Override public void configure() throws ConfigurationException { super.configure(); HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, getTimeout()); HttpConnectionParams.setSoTimeout(httpParameters, getTimeout()); httpClient = new DefaultHttpClient(connectionManager, httpParameters); httpClient.getAuthSchemes().register("NTLM", new NTLMSchemeFactory()); CredentialFactory cf = new CredentialFactory(getAuthAlias(), getUserName(), getPassword()); httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new NTCredentials(cf.getUsername(), cf.getPassword(), Misc.getHostname(), getAuthDomain())); if (StringUtils.isNotEmpty(getProxyHost())) { HttpHost proxy = new HttpHost(getProxyHost(), getProxyPort()); httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } }
Example #11
Source File: M3u8ContentParser.java From NewsMe with Apache License 2.0 | 6 votes |
private DefaultHttpClient createHttpClient() { HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); HttpProtocolParams.setUseExpectContinue(params, true); HttpConnectionParams.setConnectionTimeout(params, CONNETED_TIMEOUT * 1000); HttpConnectionParams.setSoTimeout(params, CONNETED_TIMEOUT * 1000); HttpConnectionParams.setSocketBufferSize(params, 8192); ConnManagerParams.setMaxTotalConnections(params, 4); SchemeRegistry schReg = new SchemeRegistry(); schReg.register(new Scheme("http", PlainSocketFactory .getSocketFactory(), 80)); schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); ClientConnectionManager connMgr = new ThreadSafeClientConnManager( params, schReg); return new DefaultHttpClient(connMgr, params); }
Example #12
Source File: WebServiceUtil.java From appinventor-extensions with Apache License 2.0 | 6 votes |
/** * Returns the one <code>WebServiceUtil</code> instance * @return the one <code>WebServiceUtil</code> instance */ public static WebServiceUtil getInstance() { // This needs to be here instead of in the constructor because // it uses classes that are in the AndroidSDK and thus would // cause Stub! errors when running the component descriptor. synchronized(httpClientSynchronizer) { if (httpClient == null) { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); BasicHttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, 20 * 1000); HttpConnectionParams.setSoTimeout(params, 20 * 1000); ConnManagerParams.setMaxTotalConnections(params, 20); ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params, schemeRegistry); WebServiceUtil.httpClient = new DefaultHttpClient(manager, params); } } return INSTANCE; }
Example #13
Source File: HttpClientFactory.java From NetEasyNews with GNU General Public License v3.0 | 6 votes |
private static HttpParams createHttpParams() { final HttpParams params = new BasicHttpParams(); // 设置是否启用旧连接检查,默认是开启的。关闭这个旧连接检查可以提高一点点性能,但是增加了I/O错误的风险(当服务端关闭连接时)。 // 开启这个选项则在每次使用老的连接之前都会检查连接是否可用,这个耗时大概在15-30ms之间 HttpConnectionParams.setStaleCheckingEnabled(params, false); HttpConnectionParams.setConnectionTimeout(params, TIMEOUT);// 设置链接超时时间 HttpConnectionParams.setSoTimeout(params, TIMEOUT);// 设置socket超时时间 HttpConnectionParams.setSocketBufferSize(params, SOCKET_BUFFER_SIZE);// 设置缓存大小 HttpConnectionParams.setTcpNoDelay(params, true);// 是否不使用延迟发送(true为不延迟) HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); // 设置协议版本 HttpProtocolParams.setUseExpectContinue(params, true);// 设置异常处理机制 HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);// 设置编码 HttpClientParams.setRedirecting(params, false);// 设置是否采用重定向 ConnManagerParams.setTimeout(params, TIMEOUT);// 设置超时 ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(MAX_CONNECTIONS));// 多线程最大连接数 ConnManagerParams.setMaxTotalConnections(params, 10); // 多线程总连接数 return params; }
Example #14
Source File: HttpClientFactory.java From Onosendai with Apache License 2.0 | 6 votes |
private HttpClient makeHttpClient () throws IOException, GeneralSecurityException { final HttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SO_TIMEOUT); HttpConnectionParams.setSocketBufferSize(params, SO_BUFFER_SIZE); HttpClientParams.setRedirecting(params, false); final ClientConnectionManager conman = new ThreadSafeClientConnManager(params, new SchemeRegistry()); if (this.tsPath != null) { addHttpsSchemaForTrustStore(conman, this.tsPath, this.tsPassword); } else { addHttpsSchema(conman); } return new DefaultHttpClient(conman, params); }
Example #15
Source File: Utils.java From BotLibre with Eclipse Public License 1.0 | 6 votes |
public static String httpAuthPOST(String url, String user, String password, String type, String data) throws Exception { HttpPost request = new HttpPost(url); request.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2"); StringEntity params = new StringEntity(data, "utf-8"); request.addHeader("content-type", type); request.setEntity(params); HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, URL_TIMEOUT); HttpConnectionParams.setSoTimeout(httpParams, URL_TIMEOUT); DefaultHttpClient client = new DefaultHttpClient(httpParams); client.getCredentialsProvider().setCredentials( new AuthScope(AuthScope.ANY), new UsernamePasswordCredentials(user, password)); HttpResponse response = client.execute(request); return fetchResponse(response); }
Example #16
Source File: NetworkHelper.java From fanfouapp-opensource with Apache License 2.0 | 6 votes |
private static final HttpParams createHttpParams() { final HttpParams params = new BasicHttpParams(); HttpProtocolParams.setUseExpectContinue(params, false); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); ConnManagerParams.setTimeout(params, NetworkHelper.SOCKET_TIMEOUT_MS); HttpConnectionParams.setConnectionTimeout(params, NetworkHelper.CONNECTION_TIMEOUT_MS); HttpConnectionParams.setSoTimeout(params, NetworkHelper.SOCKET_TIMEOUT_MS); ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(NetworkHelper.MAX_TOTAL_CONNECTIONS)); ConnManagerParams.setMaxTotalConnections(params, NetworkHelper.MAX_TOTAL_CONNECTIONS); HttpConnectionParams.setStaleCheckingEnabled(params, false); HttpConnectionParams.setTcpNoDelay(params, true); HttpConnectionParams.setSocketBufferSize(params, NetworkHelper.SOCKET_BUFFER_SIZE); HttpClientParams.setRedirecting(params, false); HttpProtocolParams.setUserAgent(params, "FanFou for Android/" + AppContext.appVersionName); return params; }
Example #17
Source File: ProxyController.java From subsonic with GNU General Public License v3.0 | 6 votes |
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String url = ServletRequestUtils.getRequiredStringParameter(request, "url"); HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), 15000); HttpConnectionParams.setSoTimeout(client.getParams(), 15000); HttpGet method = new HttpGet(url); InputStream in = null; try { HttpResponse resp = client.execute(method); int statusCode = resp.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { response.sendError(statusCode); } else { in = resp.getEntity().getContent(); IOUtils.copy(in, response.getOutputStream()); } } finally { IOUtils.closeQuietly(in); client.getConnectionManager().shutdown(); } return null; }
Example #18
Source File: EasySSLSocketFactory.java From PanoramaGL with Apache License 2.0 | 6 votes |
/** * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket, * java.lang.String, int, java.net.InetAddress, int, * org.apache.http.params.HttpParams) */ public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
Example #19
Source File: MyHtttpClient.java From Huochexing12306 with Apache License 2.0 | 6 votes |
public synchronized static DefaultHttpClient getHttpClient() { try { HttpParams params = new BasicHttpParams(); // 设置一些基本参数 HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); // 超时设置 // 从连接池中取连接的超时时间 ConnManagerParams.setTimeout(params, 10000); // 连接超时 HttpConnectionParams.setConnectionTimeout(params, 10000); // 请求超时 HttpConnectionParams.setSoTimeout(params, 30000); SchemeRegistry registry = new SchemeRegistry(); Scheme sch1 = new Scheme("http", PlainSocketFactory .getSocketFactory(), 80); registry.register(sch1); // 使用线程安全的连接管理来创建HttpClient ClientConnectionManager conMgr = new ThreadSafeClientConnManager( params, registry); mHttpClient = new DefaultHttpClient(conMgr, params); } catch (Exception e) { e.printStackTrace(); } return mHttpClient; }
Example #20
Source File: AsyncHttpClient.java From sealtalk-android with MIT License | 5 votes |
/** * Set the connection and socket timeout. By default, 10 seconds. * * @param timeout the connect/socket timeout in milliseconds, at least 1 second */ public void setTimeout(int timeout) { if (timeout < 1000) timeout = DEFAULT_SOCKET_TIMEOUT; this.timeout = timeout; final HttpParams httpParams = this.httpClient.getParams(); ConnManagerParams.setTimeout(httpParams, this.timeout); HttpConnectionParams.setSoTimeout(httpParams, this.timeout); HttpConnectionParams.setConnectionTimeout(httpParams, this.timeout); }
Example #21
Source File: LyricsService.java From subsonic with GNU General Public License v3.0 | 5 votes |
private String executeGetRequest(String url) throws IOException { HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), 15000); HttpConnectionParams.setSoTimeout(client.getParams(), 15000); HttpGet method = new HttpGet(url); try { ResponseHandler<String> responseHandler = new BasicResponseHandler(); return client.execute(method, responseHandler); } finally { client.getConnectionManager().shutdown(); } }
Example #22
Source File: HttpClientStack.java From pearl with Apache License 2.0 | 5 votes |
@Override public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, AuthFailureError { HttpUriRequest httpRequest = createHttpRequest(request, additionalHeaders); addHeaders(httpRequest, additionalHeaders); addHeaders(httpRequest, request.getHeaders()); onPrepareRequest(httpRequest); HttpParams httpParams = httpRequest.getParams(); int timeoutMs = request.getTimeoutMs(); // TODO: Reevaluate this connection timeout based on more wide-scale // data collection and possibly different for wifi vs. 3G. HttpConnectionParams.setConnectionTimeout(httpParams, 5000); HttpConnectionParams.setSoTimeout(httpParams, timeoutMs); return mClient.execute(httpRequest); }
Example #23
Source File: SyncHttpClient.java From sealtalk-android with MIT License | 5 votes |
/** * Set the connection and socket timeout. By default, 10 seconds. * * @param timeout * the connect/socket timeout in milliseconds, at least 1 second */ public void setTimeout(int timeout) { if (timeout < 1000) timeout = DEFAULT_SOCKET_TIMEOUT; this.timeout = timeout; final HttpParams httpParams = this.httpClient.getParams(); ConnManagerParams.setTimeout(httpParams, this.timeout); HttpConnectionParams.setSoTimeout(httpParams, this.timeout); HttpConnectionParams.setConnectionTimeout(httpParams, this.timeout); }
Example #24
Source File: EasySSLSocketFactory.java From PanoramaGL with Apache License 2.0 | 5 votes |
@Override public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3, org.apache.commons.httpclient.params.HttpConnectionParams arg4) throws IOException, UnknownHostException, org.apache.commons.httpclient.ConnectTimeoutException { return getSSLContext().getSocketFactory().createSocket(arg0, arg1, arg2, arg3); }
Example #25
Source File: HttpClientStack.java From jus with Apache License 2.0 | 5 votes |
@Override public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, AuthFailureError { HttpUriRequest httpRequest = createHttpRequest(request, additionalHeaders); addHeaders(httpRequest, additionalHeaders); addHeaders(httpRequest, request.getHeaders()); onPrepareRequest(httpRequest); HttpParams httpParams = httpRequest.getParams(); int timeoutMs = request.getTimeoutMs(); // TODO: Reevaluate this connection timeout based on more wide-scale // data collection and possibly different for wifi vs. 3G. HttpConnectionParams.setConnectionTimeout(httpParams, 5000); HttpConnectionParams.setSoTimeout(httpParams, timeoutMs); return mClient.execute(httpRequest); }
Example #26
Source File: HttpClientStack.java From TitanjumNote with Apache License 2.0 | 5 votes |
@Override public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, AuthFailureError { HttpUriRequest httpRequest = createHttpRequest(request, additionalHeaders); addHeaders(httpRequest, additionalHeaders); addHeaders(httpRequest, request.getHeaders()); onPrepareRequest(httpRequest); HttpParams httpParams = httpRequest.getParams(); int timeoutMs = request.getTimeoutMs(); // TODO: Reevaluate this connection timeout based on more wide-scale // data collection and possibly different for wifi vs. 3G. HttpConnectionParams.setConnectionTimeout(httpParams, 5000); HttpConnectionParams.setSoTimeout(httpParams, timeoutMs); return mClient.execute(httpRequest); }
Example #27
Source File: HttpHelper.java From AndroidAppCodeFramework with Apache License 2.0 | 5 votes |
/** * 添加请求超时时间和等待时间 * @return HttpClient */ public static HttpClient getHttpClient(){ BasicHttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, AppServerConfig.REQUEST_TIMEOUT); HttpConnectionParams.setSoTimeout(httpParams, AppServerConfig.DATA_TIMEOUT); return new DefaultHttpClient(httpParams); }
Example #28
Source File: ConfigurationManagerTest.java From RoboZombie with Apache License 2.0 | 5 votes |
/** * <p>Test for endpoints that uses a custom {@link HttpClient}.</p> * * @since 1.3.0 */ @Test public final void testCustomClient() { configurationManager.register(ConfigEndpoint.class); HttpClient httpClient = HttpClientDirectory.INSTANCE.lookup(ConfigEndpoint.class); assertEquals(2 * 1000, httpClient.getParams().getIntParameter(HttpConnectionParams.SO_TIMEOUT, 0)); configurationManager.register(ConfigEndpoint.class); assertTrue(HttpClientDirectory.INSTANCE.lookup(ConfigEndpoint.class) == httpClient); }
Example #29
Source File: RemoteSystemClient.java From ghwatch with Apache License 2.0 | 5 votes |
protected static DefaultHttpClient prepareHttpClient(URI uri) { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpParams params = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, 30000); HttpConnectionParams.setSoTimeout(params, 30000); return httpClient; }
Example #30
Source File: HttpUtils.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
public HttpUtils configTimeout(int timeout) { final HttpParams httpParams = this.httpClient.getParams(); ConnManagerParams.setTimeout(httpParams, timeout); HttpConnectionParams.setSoTimeout(httpParams, timeout); HttpConnectionParams.setConnectionTimeout(httpParams, timeout); return this; }