Example usage for org.apache.http.client HttpClient getConnectionManager

List of usage examples for org.apache.http.client HttpClient getConnectionManager

Introduction

In this page you can find the example usage for org.apache.http.client HttpClient getConnectionManager.

Prototype

@Deprecated
ClientConnectionManager getConnectionManager();

Source Link

Document

Obtains the connection manager used by this client.

Usage

From source file:com.lolay.android.security.OpenSSLSocketFactory.java

public static void openTrust(HttpClient client) {
    client.getConnectionManager().getSchemeRegistry()
            .register(new Scheme("https", new OpenSSLSocketFactory(), 443));
}

From source file:voldemort.utils.VoldemortIOUtils.java

public static void closeQuietly(HttpClient httpClient) {
    if (httpClient != null) {
        httpClient.getConnectionManager().shutdown();
    }//w ww .j  a va 2 s.  c  om
}

From source file:Main.java

private static void abortConnection(final HttpRequestBase httpRequestBase, final HttpClient httpclient) {
    if (httpRequestBase != null) {
        httpRequestBase.abort();//from   w w  w .ja v a2 s . c  o  m
    }
    if (httpclient != null) {
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:com.intel.cosbench.client.http.HttpClientUtil.java

/**
 * Releases the resources held by the given HTTP client.<br />
 * Note that no further connections can be made upon a disposed HTTP client.
 * //from   w ww.  j a v  a 2  s.c o  m
 * @param client
 *            the HTTP client to be disposed.
 */
public static void disposeHttpClient(HttpClient client) {
    ClientConnectionManager manager = client.getConnectionManager();
    manager.shutdown();
}

From source file:mobi.jenkinsci.ci.client.TrustAllSSLSocketFactory.java

public static void trustX509(HttpClient client, int sslPort) {

    try {//www  .jav  a  2  s  .c om

        client.getConnectionManager().getSchemeRegistry()
                .register(new Scheme("https", new TrustAllSSLSocketFactory(null), sslPort));

    } catch (KeyManagementException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (KeyStoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnrecoverableKeyException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.mingsoft.weixin.http.HttpClientConnectionManager.java

/**
 * ?SSL?HttpClient//from   w  ww  .j  ava  2 s .  co m
 * 
 * @param httpClient
 * @return
 */
public static HttpClient getSSLInstance(HttpClient httpClient) {
    ClientConnectionManager ccm = httpClient.getConnectionManager();
    SchemeRegistry sr = ccm.getSchemeRegistry();
    sr.register(new Scheme("https", 443, WeixinSSLSocketFactory.getInstance()));
    httpClient = new DefaultHttpClient(ccm, httpClient.getParams());
    return httpClient;
}

From source file:com.futureplatforms.kirin.internal.attic.IOUtils.java

public static void cleanupHttpClient(HttpClient client) {
    client.getConnectionManager().closeExpiredConnections();
}

From source file:fr.liglab.adele.cilia.workbench.restmonitoring.utils.http.HttpHelper.java

public static void put(PlatformID platformID, String target, String data) throws CiliaException {
    String url = getURL(platformID, target);
    HttpPut httpRequest = new HttpPut(url);

    // entity//from   w  w  w  .  j  a  v  a  2 s .c  o  m
    StringEntity entity = new StringEntity(data, ContentType.create("text/plain", "UTF-8"));
    httpRequest.setEntity(entity);

    // HTTP request
    HttpClient httpClient = getClient();
    try {
        httpClient.execute(httpRequest, new BasicResponseHandler());
        httpClient.getConnectionManager().shutdown();
    } catch (Exception e) {
        httpClient.getConnectionManager().shutdown();
        throw new CiliaException("can't perform HTTP PUT request", e);
    }
}

From source file:fr.liglab.adele.cilia.workbench.restmonitoring.utils.http.HttpHelper.java

public static void post(PlatformID platformID, String path, String paramName, InputStream data)
        throws CiliaException {

    String url = getURL(platformID, path);

    HttpPost httppost = new HttpPost(url);

    MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

    InputStreamBody bin = new InputStreamBody(data, paramName);
    reqEntity.addPart(paramName, bin);/*from  w  w w  . ja v  a 2  s  .com*/

    httppost.setEntity(reqEntity);

    // HTTP request
    HttpClient httpClient = getClient();
    try {
        httpClient.execute(httppost, new BasicResponseHandler());
        httpClient.getConnectionManager().shutdown();
    } catch (Exception e) {
        httpClient.getConnectionManager().shutdown();
        throw new CiliaException("can't perform HTTP PUT request", e);
    }
}

From source file:nl.igorski.lib.utils.network.HTTPTransfer.java

private static DefaultHttpClient getClient() {
    if (_httpClient == null) {
        HttpClient client = new DefaultHttpClient();

        _httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(client.getParams(),
                client.getConnectionManager().getSchemeRegistry()), client.getParams());
    }//w w  w.j av a2 s .co m
    return _httpClient;
}