Example usage for org.apache.commons.httpclient HttpsURL HttpsURL

List of usage examples for org.apache.commons.httpclient HttpsURL HttpsURL

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpsURL HttpsURL.

Prototype

public HttpsURL(char[] paramArrayOfChar) throws URIException, NullPointerException 

Source Link

Usage

From source file:org.kei.android.phone.cellhistory.towers.CellIdHelper.java

public static int tryToLocate(final Context context, final TowerInfo ti, int cfg_timeout, final String mode,
        final String apiKeyOpenCellID) {
    int timeout = cfg_timeout * 1000, ret = CellIdRequestEntity.OK;
    HttpConnectionManager connectionManager = new SimpleHttpConnectionManager();
    connectionManager.getParams().setConnectionTimeout(timeout);
    connectionManager.getParams().setSoTimeout(timeout);
    // Create a connection to some 'hidden' Google-API
    String baseURL = null;/*from ww w  . j  av a2 s .co m*/
    if (mode.equals(OPEN_CELL_ID_API)) {
        ti.lock();
        try {
            baseURL = "http://opencellid.org/cell/get?key=" + apiKeyOpenCellID + "&mcc=" + ti.getMCC() + "&mnc="
                    + ti.getMNC() + "&cellid=" + ti.getCellId() + "&lac=" + ti.getLac() + "&format=json";
        } finally {
            ti.unlock();
        }
    } else
        baseURL = "http://www.google.com/glm/mmap";
    HttpConnection connection = null;
    ti.setCellLatitude(Double.NaN);
    ti.setCellLongitude(Double.NaN);
    try {
        // Setup the connection
        HttpURL httpURL = null;
        if (baseURL.startsWith("https"))
            httpURL = new HttpsURL(baseURL);
        else
            httpURL = new HttpURL(baseURL);
        final HostConfiguration host = new HostConfiguration();
        host.setHost(httpURL.getHost(), httpURL.getPort());
        connection = connectionManager.getConnection(host);
        // Open it
        connection.open();
        if (mode.equals(OPEN_CELL_ID_API))
            ret = new OpenCellIdRequestEntity(ti).decode(baseURL, connection, timeout);
        else
            ret = new GoogleHiddenRequestEntity(ti).decode(baseURL, connection, timeout);
    } catch (Exception e) {
        Log.e(CellIdHelper.class.getSimpleName(), "Exception: " + e.getMessage(), e);
        ret = CellIdRequestEntity.EXCEPTION;
        CellHistoryApp.addLog(context, "tryToLocate::Exception: " + e.getMessage());
    } finally {
        connection.close();
    }
    connectionManager.releaseConnection(connection);
    return ret;
}

From source file:org.pengyou.ooo.utils.WebDavStore.java

private static HttpURL uriToHttpURL(String uri, String login, String password) throws URIException {
    HttpURL httpURL = uri.startsWith("https") ? new HttpsURL(uri) : new HttpURL(uri);
    if (login != null && login.length() > 0)
        httpURL.setUserinfo(login, password);
    return httpURL;

}

From source file:org.springframework.ws.transport.http.CommonsHttpMessageSender.java

/**
 * Sets the maximum number of connections per host for the underlying HttpClient. The maximum number of connections
 * per host can be set in a form accepted by the {@code java.util.Properties} class, like as follows:
 * <pre>//from   w  w  w . ja v a  2  s  . co m
 * https://www.example.com=1
 * http://www.example.com:8080=7
 * www.springframework.org=10
 * *=5
 * </pre>
 * The host can be specified as hostname, or as URI (with scheme and port). The special host name {@code *} can be
 * used to specify {@link org.apache.commons.httpclient.HostConfiguration#ANY_HOST_CONFIGURATION}.
 *
 * @param maxConnectionsPerHost a properties object specifying the maximum number of connection
 * @see org.apache.commons.httpclient.params.HttpConnectionManagerParams#setMaxConnectionsPerHost(org.apache.commons.httpclient.HostConfiguration,
 *      int)
 */
public void setMaxConnectionsPerHost(Map<String, String> maxConnectionsPerHost) throws URIException {
    for (String host : maxConnectionsPerHost.keySet()) {
        HostConfiguration hostConfiguration = new HostConfiguration();
        if ("*".equals(host)) {
            hostConfiguration = HostConfiguration.ANY_HOST_CONFIGURATION;
        } else if (host.startsWith("http://")) {
            HttpURL httpURL = new HttpURL(host);
            hostConfiguration.setHost(httpURL);
        } else if (host.startsWith("https://")) {
            HttpsURL httpsURL = new HttpsURL(host);
            hostConfiguration.setHost(httpsURL);
        } else {
            hostConfiguration.setHost(host);
        }
        int maxHostConnections = Integer.parseInt(maxConnectionsPerHost.get(host));
        getHttpClient().getHttpConnectionManager().getParams().setMaxConnectionsPerHost(hostConfiguration,
                maxHostConnections);
    }
}