当前位置: 首页>>代码示例>>Java>>正文


Java HttpConnectionParams.setSoTimeout方法代码示例

本文整理汇总了Java中org.apache.http.params.HttpConnectionParams.setSoTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java HttpConnectionParams.setSoTimeout方法的具体用法?Java HttpConnectionParams.setSoTimeout怎么用?Java HttpConnectionParams.setSoTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.params.HttpConnectionParams的用法示例。


在下文中一共展示了HttpConnectionParams.setSoTimeout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSchemeRegistry

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
public static SchemeRegistry getSchemeRegistry() {
    try {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier());
        SSLSocketFactory sf = new SSLSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 10000);
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));
        return registry;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:While1true,项目名称:JSSample,代码行数:21,代码来源:HttpUtils.java

示例2: getHttpClient

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * 从可用的HttpClient池中返回一个默认10秒的HttpClient对象,该方法是同步的。
 * 
 * @return 可用的.HttpClient对象
 */
public static synchronized HttpClient getHttpClient() {
	if (null == customerHttpClient) {
		HttpParams params = new BasicHttpParams();
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
		HttpProtocolParams.setContentCharset(params, CHARSET);
		HttpProtocolParams.setUseExpectContinue(params, true);
		HttpProtocolParams.setUserAgent(params,
						"Mozilla/5.0(Linux;U;Android 2.2.1;en-us;Nexus One Build.FRG83) "
								+ "AppleWebKit/553.1(KHTML,like Gecko) Version/4.0 Mobile Safari/533.1");
		ConnManagerParams.setTimeout(params, 10000);

		HttpConnectionParams.setConnectionTimeout(params, 10000);

		HttpConnectionParams.setSoTimeout(params, 10000);

		SchemeRegistry schReg = new SchemeRegistry();
		schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
		schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

		ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schReg);
		customerHttpClient = new DefaultHttpClient(conMgr, params);
	}
	return customerHttpClient;
}
 
开发者ID:iOnesmile,项目名称:MyAndroidDemo,代码行数:30,代码来源:CustomerHttpClient.java

示例3: createHttpClient

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
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);
}
 
开发者ID:jlertele,项目名称:SinaVideoSdkDemo,代码行数:23,代码来源:M3u8ContentParser.java

示例4: performRequest

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Ace201m,项目名称:Codeforces,代码行数:16,代码来源:HttpClientStack.java

示例5: if

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
private HttpResponse b0449щ0449щщ0449(HttpUriRequest httpUriRequest, Map map, int i) throws Exception {
    URI uri = httpUriRequest.getURI();
    String trim = uri.getHost() != null ? uri.getHost().trim() : "";
    if (trim.length() > 0) {
        httpUriRequest.setHeader("Host", trim);
    }
    if (map != null) {
        for (Object next : map.entrySet()) {
            if (((b04170417041704170417З + b0417ЗЗЗЗ0417) * b04170417041704170417З) % bЗ0417ЗЗЗ0417 != bЗЗЗЗЗ0417) {
                b04170417041704170417З = 81;
                bЗЗЗЗЗ0417 = 31;
            }
            Entry entry = (Entry) next;
            httpUriRequest.setHeader((String) entry.getKey(), (String) entry.getValue());
        }
    }
    Header[] allHeaders = httpUriRequest.getAllHeaders();
    Log.d(b043D043Dнн043Dн, "request URI [" + httpUriRequest.getURI() + "]");
    for (Object obj : allHeaders) {
        Log.d(b043D043Dнн043Dн, "request header [" + obj.toString() + "]");
    }
    HttpConnectionParams.setSoTimeout(this.bнн043Dн043Dн.getParams(), i);
    HttpResponse execute = this.bнн043Dн043Dн.execute(httpUriRequest);
    if (execute != null) {
        return execute;
    }
    throw new RuntimeException("Null response returned.");
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:29,代码来源:ImmersionHttpClient.java

示例6: create

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * HTTPClientオブジェクトを作成.
 * @param type 通信タイプ
 * @param connectionTimeout タイムアウト値(ミリ秒)。0の場合はデフォルト値を利用する。
 * @return 作成したHttpClientクラスインスタンス
 */
public static HttpClient create(final String type, final int connectionTimeout) {
    if (TYPE_DEFAULT.equalsIgnoreCase(type)) {
        return new DefaultHttpClient();
    }

    SSLSocketFactory sf = null;
    try {
        if (TYPE_INSECURE.equalsIgnoreCase(type)) {
            sf = createInsecureSSLSocketFactory();
        }
    } catch (Exception e) {
        return null;
    }

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("https", PORTHTTPS, sf));
    schemeRegistry.register(new Scheme("http", PORTHTTP, PlainSocketFactory.getSocketFactory()));
    HttpParams params = new BasicHttpParams();
    ClientConnectionManager cm = new SingleClientConnManager(schemeRegistry);
    // ClientConnectionManager cm = new
    // ThreadSafeClientConnManager(schemeRegistry);
    HttpClient hc = new DefaultHttpClient(cm, params);

    HttpParams params2 = hc.getParams();
    int timeout = TIMEOUT;
    if (connectionTimeout != 0) {
        timeout = connectionTimeout;
    }
    HttpConnectionParams.setConnectionTimeout(params2, timeout); // 接続のタイムアウト
    HttpConnectionParams.setSoTimeout(params2, timeout); // データ取得のタイムアウト
    return hc;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:39,代码来源:HttpClientFactory.java

示例7: a

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
public static b a() {
    if (b == null) {
        HttpParams basicHttpParams = new BasicHttpParams();
        HttpProtocolParams.setVersion(basicHttpParams, HttpVersion.HTTP_1_1);
        HttpConnectionParams.setStaleCheckingEnabled(basicHttpParams, true);
        basicHttpParams.setBooleanParameter("http.protocol.expect-continue", false);
        ConnManagerParams.setMaxTotalConnections(basicHttpParams, 50);
        ConnManagerParams.setMaxConnectionsPerRoute(basicHttpParams, new ConnPerRouteBean(30));
        ConnManagerParams.setTimeout(basicHttpParams, 1000);
        HttpConnectionParams.setConnectionTimeout(basicHttpParams, 20000);
        HttpConnectionParams.setSoTimeout(basicHttpParams, 30000);
        HttpConnectionParams.setSocketBufferSize(basicHttpParams, 16384);
        HttpProtocolParams.setUseExpectContinue(basicHttpParams, false);
        HttpClientParams.setRedirecting(basicHttpParams, true);
        HttpClientParams.setAuthenticating(basicHttpParams, false);
        HttpProtocolParams.setUserAgent(basicHttpParams, a);
        try {
            SocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
            socketFactory.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
            Scheme scheme = new Scheme(com.alipay.sdk.cons.b.a, socketFactory, WebSocket.DEFAULT_WSS_PORT);
            Scheme scheme2 = new Scheme("http", PlainSocketFactory.getSocketFactory(), 80);
            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(scheme);
            schemeRegistry.register(scheme2);
            b = new b(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry), basicHttpParams);
        } catch (Exception e) {
            b = new b(basicHttpParams);
        }
    }
    return b;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:32,代码来源:b.java

示例8: setTimeout

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:zqHero,项目名称:rongyunDemo,代码行数:14,代码来源:SyncHttpClient.java

示例9: createClientLoginHelper

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
private IClientLoginHelper createClientLoginHelper(String accountPrompt, String service) {
  if (SdkLevel.getLevel() >= SdkLevel.LEVEL_ECLAIR) {
    HttpClient httpClient = new DefaultHttpClient();
    HttpConnectionParams.setSoTimeout(httpClient.getParams(), SERVER_TIMEOUT_MS);
    HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), SERVER_TIMEOUT_MS);
    return new ClientLoginHelper(activity, service, accountPrompt, httpClient);
  }
  return null;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:10,代码来源:FusiontablesControl.java

示例10: configTimeout

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
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;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:8,代码来源:HttpUtils.java

示例11: getHttpClient

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
public DefaultHttpClient getHttpClient()
{
    BasicHttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, REQUEST_TIMEOUT);
    HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
    DefaultHttpClient client = new DefaultHttpClient(httpParams);
    client.getParams().setParameter(
CoreProtocolPNames.HTTP_CONTENT_CHARSET, "gb2312");
    return client;
}
 
开发者ID:pengbing92,项目名称:MyMusicPlayer,代码行数:11,代码来源:MyClient.java

示例12: setHttpClientParameters

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * Sets the parameters to the request
 *
 * @param params
 *            The parameters to be set
 * @param the socket time out.
 */
private static void setHttpClientParameters(HttpParams params, Integer socketTimeOut) {

	HttpProtocolParams
			.setContentCharset(params, Constants.DEFAULT_ENCODING);
	HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT);
	HttpConnectionParams.setSoTimeout(params, socketTimeOut);
}
 
开发者ID:developers-payu-latam,项目名称:payu-latam-java-payments-sdk,代码行数:15,代码来源:HttpClientHelper.java

示例13: executeGetRequest

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:15,代码来源:LyricsService.java

示例14: getContent

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
/**
 * 传入网络地址,并构造可以操作中断的HttpClientIO对象,返回字符串,此方法是同步的
 * 
 * @param url
 * @return 字符串结果
 * @throws Exception
 */
public static String getContent(String url, HttpClientIO hcio) throws Exception {
	StringBuilder sb = new StringBuilder();
	HttpClient client = getHttpClient();
	HttpParams httpParams = client.getParams();

	HttpConnectionParams.setConnectionTimeout(httpParams, 6000);
	HttpConnectionParams.setSoTimeout(httpParams, 6000);
	HttpResponse response = client.execute(new HttpGet(url));
	HttpEntity entity = response.getEntity();

	if (entity != null) {
		InputStream is = entity.getContent();
		// 回调
		if (hcio != null) {
			hcio.setInputStream(is);

			hcio.setHttpEntity(entity);
		}
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				is, "UTF-8"), 1024);
		String line = null;
		while ((line = reader.readLine()) != null) {
			sb.append(line + "\n");
		}

		reader.close();
	}
	return sb.toString();
}
 
开发者ID:iOnesmile,项目名称:MyAndroidDemo,代码行数:37,代码来源:CustomerHttpClient.java

示例15: SimpleHttpClient

import org.apache.http.params.HttpConnectionParams; //导入方法依赖的package包/类
public SimpleHttpClient() {
    this.client = new DefaultHttpClient(new ThreadSafeClientConnManager());
    HttpParams params = client.getParams();
    HttpConnectionParams.setConnectionTimeout(params, 30000);
    HttpConnectionParams.setSoTimeout(params, 30000);
    client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
        public boolean retryRequest(IOException e, int i, HttpContext httpContext) {
            return false;
        }
    });
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:12,代码来源:SimpleHttpClient.java


注:本文中的org.apache.http.params.HttpConnectionParams.setSoTimeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。