多线程安全的HTTPCLIENT

private static HttpClient httpClient;
    static {
 
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params,
                HTTP.DEFAULT_CONTENT_CHARSET);
        HttpProtocolParams.setUseExpectContinue(params, true);
 
        // 设置timeout
        HttpConnectionParams.setConnectionTimeout(params, 5 * 1000);
        HttpConnectionParams.setSoTimeout(params, 5 * 1000);
        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);
 
        httpClient = new DefaultHttpClient(conMgr, params);
    }
 
上一篇:angularjs中类似textarea的换行、空格处理


下一篇:ORA-06575:程序包或函数处于无效状态