Search in sources :

Example 1 with OkHttpsURLConnection

use of okhttp3.internal.huc.OkHttpsURLConnection in project okhttp by square.

the class OkUrlFactory method open.

HttpURLConnection open(URL url, Proxy proxy) {
    String protocol = url.getProtocol();
    OkHttpClient copy = client.newBuilder().proxy(proxy).build();
    if (protocol.equals("http"))
        return new OkHttpURLConnection(url, copy, urlFilter);
    if (protocol.equals("https"))
        return new OkHttpsURLConnection(url, copy, urlFilter);
    throw new IllegalArgumentException("Unexpected protocol: " + protocol);
}
Also used : OkHttpsURLConnection(okhttp3.internal.huc.OkHttpsURLConnection) OkHttpURLConnection(okhttp3.internal.huc.OkHttpURLConnection)

Example 2 with OkHttpsURLConnection

use of okhttp3.internal.huc.OkHttpsURLConnection in project NoHttp by yanzhenjie.

the class URLConnectionFactory method open.

/**
     * Open url.
     *
     * @param url   {@link URL}.
     * @param proxy {@link Proxy}.
     * @return {@link HttpURLConnection}.
     */
public HttpURLConnection open(URL url, Proxy proxy) {
    OkHttpClient copy = mClient.newBuilder().proxy(proxy).build();
    String protocol = url.getProtocol();
    if (protocol.equals("http"))
        return new OkHttpURLConnection(url, copy);
    if (protocol.equals("https"))
        return new OkHttpsURLConnection(url, copy);
    throw new IllegalArgumentException("Unexpected protocol: " + protocol);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) OkHttpsURLConnection(okhttp3.internal.huc.OkHttpsURLConnection) OkHttpURLConnection(okhttp3.internal.huc.OkHttpURLConnection)

Aggregations

OkHttpURLConnection (okhttp3.internal.huc.OkHttpURLConnection)2 OkHttpsURLConnection (okhttp3.internal.huc.OkHttpsURLConnection)2 OkHttpClient (okhttp3.OkHttpClient)1