cz.msebera.android.httpclient.client.HttpClient.getParams()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中cz.msebera.android.httpclient.client.HttpClient.getParams()方法的一些代码示例,展示了HttpClient.getParams()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.getParams()方法的具体详情如下:
包路径:cz.msebera.android.httpclient.client.HttpClient
类名称:HttpClient
方法名:getParams

HttpClient.getParams介绍

[英]Obtains the parameters for this client. These parameters will become defaults for all requests being executed with this client, and for the parameters of dependent objects in this client.
[中]获取此客户端的参数。这些参数将成为使用此客户端执行的所有请求以及此客户端中依赖对象的参数的默认值。

代码示例

代码示例来源:origin: cz.msebera.android/httpclient

public HttpParams getParams() {
  return backend.getParams();
}

代码示例来源:origin: cz.msebera.android/httpclient

public HttpParams getParams() {
  return backend.getParams();
}

代码示例来源:origin: andstatus/andstatus

static HttpClient getHttpClient() {
  SchemeRegistry schemeRegistry = new SchemeRegistry();
  schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
  
  SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
  // This is done to get rid of the "javax.net.ssl.SSLException: hostname in certificate didn't match" error
  // See e.g. http://stackoverflow.com/questions/8839541/hostname-in-certificate-didnt-match
  socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);        
  schemeRegistry.register(new Scheme("https", socketFactory, 443));
  HttpParams params = getHttpParams();        
  ClientConnectionManager clientConnectionManager = new ThreadSafeClientConnManager(params, schemeRegistry);
  HttpClient client = new DefaultHttpClient(clientConnectionManager, params);
  client.getParams()
      .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
          MyPreferences.getConnectionTimeoutMs())
      .setIntParameter(CoreConnectionPNames.SO_TIMEOUT,
          MyPreferences.getConnectionTimeoutMs());
  return client;
}

相关文章