Example usage for org.apache.http.conn.scheme Scheme getName

List of usage examples for org.apache.http.conn.scheme Scheme getName

Introduction

In this page you can find the example usage for org.apache.http.conn.scheme Scheme getName.

Prototype

public final String getName() 

Source Link

Document

Obtains the scheme name.

Usage

From source file:com.qiniu.android.http.ClientConnectionOperator.java

public void updateSecureConnection(OperatedClientConnection conn, HttpHost target, HttpContext context,
        HttpParams params) throws IOException {
    if (conn == null) {
        throw new IllegalArgumentException("Connection must not be null.");
    }/*  w  w w.j a v  a 2 s. co  m*/
    if (target == null) {
        throw new IllegalArgumentException("Target host must not be null.");
    }
    if (params == null) {
        throw new IllegalArgumentException("Parameters must not be null.");
    }
    if (!conn.isOpen()) {
        throw new IllegalArgumentException("Connection must be open.");
    }

    final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
    if (!(schm.getSocketFactory() instanceof LayeredSocketFactory)) {
        throw new IllegalArgumentException(
                "Target scheme (" + schm.getName() + ") must have layered socket factory.");
    }

    final LayeredSocketFactory lsf = (LayeredSocketFactory) schm.getSocketFactory();
    final Socket sock;
    try {
        sock = lsf.createSocket(conn.getSocket(), target.getHostName(), target.getPort(), true);
    } catch (ConnectException ex) {
        throw new HttpHostConnectException(target, ex);
    }
    prepareSocket(sock, context, params);
    conn.update(sock, target, lsf.isSecure(sock), params);
}

From source file:com.soundcloud.playerapi.ApiWrapper.java

/**
 * @param proxy the proxy to use for the wrapper, or null to clear the current one.
 *//*w ww  .  j a  v a 2s  .c o m*/
public void setProxy(URI proxy) {
    final HttpHost host;
    if (proxy != null) {
        Scheme scheme = getHttpClient().getConnectionManager().getSchemeRegistry().getScheme(proxy.getScheme());

        host = new HttpHost(proxy.getHost(), scheme.resolvePort(proxy.getPort()), scheme.getName());
    } else {
        host = null;
    }
    getHttpClient().getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, host);
}