what-the-bank/sources/okhttp3/repackaged/OkUrlFactory.java

93 lines
2.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.repackaged;
import io.grpc.internal.GrpcUtil;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import okhttp3.repackaged.internal.URLFilter;
import okhttp3.repackaged.internal.huc.HttpURLConnectionImpl;
import okhttp3.repackaged.internal.huc.HttpsURLConnectionImpl;
/* loaded from: classes6.dex */
public final class OkUrlFactory implements Cloneable, URLStreamHandlerFactory {
private URLFilter aip;
private OkHttpClient client;
public OkUrlFactory(OkHttpClient okHttpClient) {
this.client = okHttpClient;
}
public final OkUrlFactory clone() {
return new OkUrlFactory(this.client);
}
public final HttpURLConnection open(URL url) {
return a(url, this.client.proxy());
}
final HttpURLConnection a(URL url, Proxy proxy) {
String protocol = url.getProtocol();
OkHttpClient build = this.client.newBuilder().proxy(proxy).build();
if (protocol.equals("http")) {
return new HttpURLConnectionImpl(url, build, this.aip);
}
if (protocol.equals("https")) {
return new HttpsURLConnectionImpl(url, build, this.aip);
}
throw new IllegalArgumentException("Unexpected protocol: ".concat(String.valueOf(protocol)));
}
@Override // java.net.URLStreamHandlerFactory
public final URLStreamHandler createURLStreamHandler(String str) {
if (str.equals("http") || str.equals("https")) {
return new URLStreamHandler(this, str) { // from class: okhttp3.repackaged.OkUrlFactory.1
final String aiq;
final OkUrlFactory air;
{
this.air = this;
this.aiq = str;
}
@Override // java.net.URLStreamHandler
protected URLConnection openConnection(URL url) {
return this.air.open(url);
}
@Override // java.net.URLStreamHandler
protected URLConnection openConnection(URL url, Proxy proxy) {
return this.air.a(url, proxy);
}
@Override // java.net.URLStreamHandler
protected int getDefaultPort() {
if (this.aiq.equals("http")) {
return 80;
}
if (this.aiq.equals("https")) {
return GrpcUtil.DEFAULT_PORT_SSL;
}
throw new AssertionError();
}
};
}
return null;
}
public final OkUrlFactory setClient(OkHttpClient okHttpClient) {
this.client = okHttpClient;
return this;
}
public final OkHttpClient client() {
return this.client;
}
final void a(URLFilter uRLFilter) {
this.aip = uRLFilter;
}
}