當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpProtocolParams.setUseExpectContinue方法代碼示例

本文整理匯總了Java中org.apache.http.params.HttpProtocolParams.setUseExpectContinue方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpProtocolParams.setUseExpectContinue方法的具體用法?Java HttpProtocolParams.setUseExpectContinue怎麽用?Java HttpProtocolParams.setUseExpectContinue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.params.HttpProtocolParams的用法示例。


在下文中一共展示了HttpProtocolParams.setUseExpectContinue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: get

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
public static HttpClient get() {
    HttpParams httpParams = new BasicHttpParams();
    ConnManagerParams.setTimeout(httpParams, 3000);
    ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(30));
    ConnManagerParams.setMaxTotalConnections(httpParams, 30);
    HttpClientParams.setRedirecting(httpParams, true);
    HttpProtocolParams.setUseExpectContinue(httpParams, true);
    HttpConnectionParams.setStaleCheckingEnabled(httpParams, false);
    HttpConnectionParams.setSoTimeout(httpParams, 2000);
    HttpConnectionParams.setConnectionTimeout(httpParams, 2000);
    HttpConnectionParams.setTcpNoDelay(httpParams, true);
    HttpConnectionParams.setSocketBufferSize(httpParams, 8192);
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme(IDataSource.SCHEME_HTTP_TAG, PlainSocketFactory.getSocketFactory(), 80));
    try {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        schemeRegistry.register(new Scheme(IDataSource.SCHEME_HTTPS_TAG, sf, 443));
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams, schemeRegistry), httpParams);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:26,代碼來源:PoolingClientConnectionManager.java

示例2: a

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
public static b a(String str) {
    HttpParams basicHttpParams = new BasicHttpParams();
    HttpProtocolParams.setVersion(basicHttpParams, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(basicHttpParams, false);
    HttpConnectionParams.setStaleCheckingEnabled(basicHttpParams, false);
    HttpConnectionParams.setConnectionTimeout(basicHttpParams, 20000);
    HttpConnectionParams.setSoTimeout(basicHttpParams, 30000);
    HttpConnectionParams.setSocketBufferSize(basicHttpParams, 8192);
    HttpClientParams.setRedirecting(basicHttpParams, true);
    HttpClientParams.setAuthenticating(basicHttpParams, false);
    HttpProtocolParams.setUserAgent(basicHttpParams, str);
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    schemeRegistry.register(new Scheme(com.alipay.sdk.cons.b.a, SSLCertificateSocketFactory.getHttpSocketFactory(30000, null), WebSocket.DEFAULT_WSS_PORT));
    ClientConnectionManager threadSafeClientConnManager = new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry);
    ConnManagerParams.setTimeout(basicHttpParams, 60000);
    ConnManagerParams.setMaxConnectionsPerRoute(basicHttpParams, new ConnPerRouteBean(10));
    ConnManagerParams.setMaxTotalConnections(basicHttpParams, 50);
    Security.setProperty("networkaddress.cache.ttl", "-1");
    HttpsURLConnection.setDefaultHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
    return new b(threadSafeClientConnManager, basicHttpParams);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:b.java

示例3: createHttpClient

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
/**
 * 設置默認請求參數,並返回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;

}
 
開發者ID:henrymorgen,項目名稱:android-advanced-light,代碼行數:21,代碼來源:MainActivity.java

示例4: createHttpParams

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
private HttpParams createHttpParams() {
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, "UTF-8");
    HttpProtocolParams.setUseExpectContinue(params, false);
    ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(3));
    ConnManagerParams.setMaxTotalConnections(params, 3);
    ConnManagerParams.setTimeout(params, 1000);
    HttpConnectionParams.setConnectionTimeout(params, 30000);
    HttpConnectionParams.setSoTimeout(params, 30000);
    HttpConnectionParams.setStaleCheckingEnabled(params, false);
    HttpConnectionParams.setTcpNoDelay(params, true);
    HttpConnectionParams.setSocketBufferSize(params, 8192);
    HttpClientParams.setRedirecting(params, false);
    return params;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:17,代碼來源:HttpEngine.java

示例5: init

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
static void init(final NetLayer lowerNetLayer)
	{
		try
		{
			HttpClientUtil.lowerNetLayer = lowerNetLayer;
			final Scheme http = new Scheme("http", new NetlibSocketFactory(lowerNetLayer), 80);

			supportedSchemes = new SchemeRegistry();
			supportedSchemes.register(http);

			// prepare parameters
			final HttpParams httpParams = new BasicHttpParams();
			HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
			HttpProtocolParams.setContentCharset(httpParams, Util.UTF8);
			HttpProtocolParams.setUseExpectContinue(httpParams, true);

//			connMgr = new ThreadSafeClientConnManager(httpParams, supportedSchemes);

		}
		catch (final Exception e)
		{
			LOG.error("error during class init", e);
		}
	}
 
開發者ID:B4dT0bi,項目名稱:silvertunnel-ng,代碼行數:25,代碼來源:HttpClientUtil.java

示例6: createHttpClient

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的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:iQuick,項目名稱:NewsMe,代碼行數:23,代碼來源:M3u8ContentParser.java

示例7: createHttpParams

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
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;
}
 
開發者ID:cuilitang,項目名稱:CuiMarket,代碼行數:20,代碼來源:HttpClientFactory.java

示例8: setup

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
/**
 * Performs general setup.
 * This should be called only once.
 */
private final static void setup() {

    // Register the "http" and "https" protocol schemes, they are
    // required by the default operator to look up socket factories.
    supportedSchemes = new SchemeRegistry();
    SocketFactory sf = PlainSocketFactory.getSocketFactory();
    supportedSchemes.register(new Scheme("http", sf, 80));
    sf = SSLSocketFactory.getSocketFactory();
    supportedSchemes.register(new Scheme("https", sf, 80));

    // Prepare parameters.
    // Since this example doesn't use the full core framework,
    // only few parameters are actually required.
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(params, false);
    defaultParameters = params;

}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:24,代碼來源:ManagerConnectProxy.java

示例9: setup

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
/**
 * Performs general setup.
 * This should be called only once.
 */
private final static void setup() {

    // Register the "http" protocol scheme, it is required
    // by the default operator to look up socket factories.
    supportedSchemes = new SchemeRegistry();
    SocketFactory sf = PlainSocketFactory.getSocketFactory();
    supportedSchemes.register(new Scheme("http", sf, 80));

    // Prepare parameters.
    // Since this example doesn't use the full core framework,
    // only few parameters are actually required.
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(params, false);
    defaultParameters = params;

}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:22,代碼來源:ManagerConnectDirect.java

示例10: getHttpClient

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的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

示例11: XMLRPCClient

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
/**
 * XMLRPCClient constructor. Creates new instance based on server URI
 * @param uri xml-rpc server URI
 */
public XMLRPCClient(URI uri, String httpuser, String httppasswd) {
    mPostMethod = new HttpPost(uri);
    mPostMethod.addHeader("Content-Type", "text/xml");
    mPostMethod.addHeader("charset", "UTF-8");
    mPostMethod.addHeader("User-Agent", WordPress.getUserAgent());
    addWPComAuthorizationHeaderIfNeeded();

    mHttpParams = mPostMethod.getParams();
    HttpProtocolParams.setUseExpectContinue(mHttpParams, false);

    UsernamePasswordCredentials credentials = null;
    if (!TextUtils.isEmpty(httpuser) && !TextUtils.isEmpty(httppasswd)) {
        credentials = new UsernamePasswordCredentials(httpuser, httppasswd);
    }

    mClient = instantiateClientForUri(uri, credentials);
    mSerializer = Xml.newSerializer();
}
 
開發者ID:ldsddn,項目名稱:wordpress_app_android,代碼行數:23,代碼來源:XMLRPCClient.java

示例12: init

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
static void init(final NetLayer lowerNetLayer)
	{
		try
		{
			HttpClientUtil.lowerNetLayer = lowerNetLayer;
			final Scheme http = new Scheme("http", new NetlibSocketFactory(lowerNetLayer), 80);

			supportedSchemes = new SchemeRegistry();
			supportedSchemes.register(http);

			// prepare parameters
			final HttpParams httpParams = new BasicHttpParams();
			HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
			HttpProtocolParams.setContentCharset(httpParams, Util.UTF8);
			HttpProtocolParams.setUseExpectContinue(httpParams, true);

//			connMgr = new ThreadSafeClientConnManager(httpParams, supportedSchemes);

		}
		catch (final Exception e)
		{
			logger.error("error during class init", e);
		}
	}
 
開發者ID:rovemonteux,項目名稱:silvertunnel-monteux,代碼行數:25,代碼來源:HttpClientUtil.java

示例13: getHttpClient

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
public synchronized HttpClient getHttpClient() {
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(params, true);
    // 設置連接管理器的超時
    ConnManagerParams.setTimeout(params, 10000);
    // 設置連接超時
    HttpConnectionParams.setConnectionTimeout(params, 10000);
    // 設置socket超時
    HttpConnectionParams.setSoTimeout(params, 10000);
    SchemeRegistry schReg = new SchemeRegistry();
    // 設置https的支持
    schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    //設置HTTP支持
    schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    ClientConnectionManager conManager = new ThreadSafeClientConnManager(params, schReg);
    HttpClient httpClient = new DefaultHttpClient(conManager, params);
    return httpClient;
}
 
開發者ID:renhui,項目名稱:android_career,代碼行數:21,代碼來源:HttpRunnable.java

示例14: getNewHttpClient

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
private HttpClient getNewHttpClient() {
	try {
		KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
		trustStore.load(null, null);
		SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
		sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

		HttpParams params = new BasicHttpParams();
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
		HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
		HttpProtocolParams.setUseExpectContinue(params, true);
		// ConnManagerParams.setTimeout(params, 10000);
		HttpConnectionParams.setConnectionTimeout(params, 20000);
		HttpConnectionParams.setSoTimeout(params, 20000);

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

		ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
		return new DefaultHttpClient(ccm, params);
	} catch (Exception e) {
		return new DefaultHttpClient();
	}
}
 
開發者ID:thoinv,項目名稱:kaorisan,代碼行數:26,代碼來源:NetworkService.java

示例15: ConnectionHelper

import org.apache.http.params.HttpProtocolParams; //導入方法依賴的package包/類
private ConnectionHelper() {
	HttpParams httpParams = new BasicHttpParams();
	ConnManagerParams.setMaxTotalConnections(httpParams,
			MAX_TOTAL_CONNECTIONS);
	ConnPerRouteBean connPerRoute = new ConnPerRouteBean(
			MAX_CONNECTIONS_PER_HOST);
	ConnManagerParams.setMaxConnectionsPerRoute(httpParams, connPerRoute);

	HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
	HttpProtocolParams.setUseExpectContinue(httpParams, false);
	SchemeRegistry reg = new SchemeRegistry();
	reg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(),
			80));
	reg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(),
			443));
	ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(
			httpParams, reg);
	HttpConnectionParams.setConnectionTimeout(httpParams, CON_TIME_OUT_MS);
	HttpConnectionParams.setSoTimeout(httpParams, SO_TIME_OUT_MS);

	HttpClientParams.setCookiePolicy(httpParams,
			CookiePolicy.BROWSER_COMPATIBILITY);
	httpClient = new DefaultHttpClient(connectionManager, httpParams);
}
 
開發者ID:shenkaige,項目名稱:AndroidHttpTools,代碼行數:25,代碼來源:ConnectionHelper.java


注:本文中的org.apache.http.params.HttpProtocolParams.setUseExpectContinue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。