what-the-bank/sources/okhttp3/HttpUrl.java

1696 lines
68 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3;
import io.grpc.internal.GrpcUtil;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import o.C14851gaI;
import o.C14953gcr;
import o.C14957gcv;
import o.C14969gda;
import o.C14973gde;
import o.C14977gdi;
import o.C15111ghZ;
import o.gaH;
import o.gbB;
import o.gdP;
import o.gdW;
import o.gdZ;
import okhttp3.internal.HostnamesKt;
import okhttp3.internal.Util;
import okhttp3.internal.publicsuffix.PublicSuffixDatabase;
import org.bouncycastle.math.Primes;
/* loaded from: classes.dex */
public final class HttpUrl {
public static final String FORM_ENCODE_SET = " \"':;<=>@[]^`{}|/\\?#&!$(),~";
public static final String FRAGMENT_ENCODE_SET = "";
public static final String FRAGMENT_ENCODE_SET_URI = " \"#<>\\^`{|}";
public static final String PASSWORD_ENCODE_SET = " \"':;<=>@[]^`{}|/\\?#";
public static final String PATH_SEGMENT_ENCODE_SET = " \"<>^`{}|/\\?#";
public static final String PATH_SEGMENT_ENCODE_SET_URI = "[]";
public static final String QUERY_COMPONENT_ENCODE_SET = " !\"#$&'(),/:;<=>?@[]\\^`{|}~";
public static final String QUERY_COMPONENT_ENCODE_SET_URI = "\\^`{|}";
public static final String QUERY_COMPONENT_REENCODE_SET = " \"'<>#&=";
public static final String QUERY_ENCODE_SET = " \"'<>#";
public static final String USERNAME_ENCODE_SET = " \"':;<=>@[]^`{}|/\\?#";
private final String fragment;
private final String host;
private final boolean isHttps;
private final String password;
private final List<String> pathSegments;
private final int port;
private final List<String> queryNamesAndValues;
private final String scheme;
private final String url;
private final String username;
public static final Companion Companion = new Companion(null);
private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public HttpUrl(String str, String str2, String str3, String str4, int i, List<String> list, List<String> list2, String str5, String str6) {
C14957gcv.e(str, "");
C14957gcv.e(str2, "");
C14957gcv.e(str3, "");
C14957gcv.e(str4, "");
C14957gcv.e(list, "");
C14957gcv.e(str6, "");
this.scheme = str;
this.username = str2;
this.password = str3;
this.host = str4;
this.port = i;
this.pathSegments = list;
this.queryNamesAndValues = list2;
this.fragment = str5;
this.url = str6;
this.isHttps = C14957gcv.b((Object) str, (Object) "https");
}
public final URL url() {
try {
return new URL(this.url);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
public final URI uri() {
String obj = newBuilder().reencodeForUri$okhttp().toString();
try {
return new URI(obj);
} catch (URISyntaxException e) {
try {
URI create = URI.create(new gdW("[\\u0000-\\u001F\\u007F-\\u009F\\p{javaWhitespace}]").a(obj, ""));
C14957gcv.c(create, "");
return create;
} catch (Exception unused) {
throw new RuntimeException(e);
}
}
}
public final String encodedUsername() {
if (this.username.length() == 0) {
return "";
}
int length = this.scheme.length() + 3;
String str = this.url;
String substring = this.url.substring(length, Util.delimiterOffset(str, ":@", length, str.length()));
C14957gcv.c((Object) substring, "");
return substring;
}
public final String encodedPassword() {
if (this.password.length() == 0) {
return "";
}
int a = gdZ.a((CharSequence) this.url, ':', this.scheme.length() + 3, false);
String substring = this.url.substring(a + 1, gdZ.a((CharSequence) this.url, '@', 0, false));
C14957gcv.c((Object) substring, "");
return substring;
}
public final int pathSize() {
return this.pathSegments.size();
}
public final String encodedPath() {
int a = gdZ.a((CharSequence) this.url, '/', this.scheme.length() + 3, false);
String str = this.url;
String substring = this.url.substring(a, Util.delimiterOffset(str, "?#", a, str.length()));
C14957gcv.c((Object) substring, "");
return substring;
}
public final List<String> encodedPathSegments() {
int a = gdZ.a((CharSequence) this.url, '/', this.scheme.length() + 3, false);
String str = this.url;
int delimiterOffset = Util.delimiterOffset(str, "?#", a, str.length());
ArrayList arrayList = new ArrayList();
while (a < delimiterOffset) {
int i = a + 1;
int delimiterOffset2 = Util.delimiterOffset(this.url, '/', i, delimiterOffset);
String substring = this.url.substring(i, delimiterOffset2);
C14957gcv.c((Object) substring, "");
arrayList.add(substring);
a = delimiterOffset2;
}
return arrayList;
}
public final String encodedQuery() {
if (this.queryNamesAndValues == null) {
return null;
}
int a = gdZ.a((CharSequence) this.url, '?', 0, false) + 1;
String str = this.url;
String substring = this.url.substring(a, Util.delimiterOffset(str, '#', a, str.length()));
C14957gcv.c((Object) substring, "");
return substring;
}
public final String query() {
if (this.queryNamesAndValues == null) {
return null;
}
StringBuilder sb = new StringBuilder();
Companion.toQueryString$okhttp(this.queryNamesAndValues, sb);
return sb.toString();
}
public final int querySize() {
List<String> list = this.queryNamesAndValues;
if (list != null) {
return list.size() / 2;
}
return 0;
}
public final String queryParameter(String str) {
C14973gde c14973gde;
C14957gcv.e(str, "");
List<String> list = this.queryNamesAndValues;
if (list == null) {
return null;
}
int size = list.size();
if (size <= Integer.MIN_VALUE) {
C14973gde.LWm lWm = C14973gde.c;
c14973gde = C14973gde.f;
} else {
c14973gde = new C14973gde(0, size - 1);
}
C14969gda b = C14977gdi.b(c14973gde, 2);
int i = b.b;
int i2 = b.d;
int i3 = b.e;
if ((i3 > 0 && i <= i2) || (i3 < 0 && i2 <= i)) {
while (!C14957gcv.b((Object) str, (Object) this.queryNamesAndValues.get(i))) {
if (i != i2) {
i += i3;
}
}
return this.queryNamesAndValues.get(i + 1);
}
return null;
}
public final String queryParameterName(int i) {
List<String> list = this.queryNamesAndValues;
if (list == null) {
throw new IndexOutOfBoundsException();
}
String str = list.get(i << 1);
C14957gcv.e(str);
return str;
}
public final String queryParameterValue(int i) {
List<String> list = this.queryNamesAndValues;
if (list == null) {
throw new IndexOutOfBoundsException();
}
return list.get((i << 1) + 1);
}
public final String encodedFragment() {
if (this.fragment == null) {
return null;
}
String substring = this.url.substring(gdZ.a((CharSequence) this.url, '#', 0, false) + 1);
C14957gcv.c((Object) substring, "");
return substring;
}
public final String redact() {
Builder newBuilder = newBuilder("/...");
C14957gcv.e(newBuilder);
return newBuilder.username("").password("").build().toString();
}
public final HttpUrl resolve(String str) {
C14957gcv.e(str, "");
Builder newBuilder = newBuilder(str);
if (newBuilder == null) {
return null;
}
return newBuilder.build();
}
public final Builder newBuilder() {
Builder builder = new Builder();
builder.setScheme$okhttp(this.scheme);
builder.setEncodedUsername$okhttp(encodedUsername());
builder.setEncodedPassword$okhttp(encodedPassword());
builder.setHost$okhttp(this.host);
builder.setPort$okhttp(this.port != Companion.defaultPort(this.scheme) ? this.port : -1);
builder.getEncodedPathSegments$okhttp().clear();
builder.getEncodedPathSegments$okhttp().addAll(encodedPathSegments());
builder.encodedQuery(encodedQuery());
builder.setEncodedFragment$okhttp(encodedFragment());
return builder;
}
public final Builder newBuilder(String str) {
C14957gcv.e(str, "");
try {
return new Builder().parse$okhttp(this, str);
} catch (IllegalArgumentException unused) {
return null;
}
}
public final boolean equals(Object obj) {
return (obj instanceof HttpUrl) && C14957gcv.b((Object) ((HttpUrl) obj).url, (Object) this.url);
}
public final int hashCode() {
return this.url.hashCode();
}
public final String topPrivateDomain() {
if (Util.canParseAsIpAddress(this.host)) {
return null;
}
return PublicSuffixDatabase.Companion.get().getEffectiveTldPlusOne(this.host);
}
/* renamed from: -deprecated_url, reason: not valid java name */
public final URL m425deprecated_url() {
return url();
}
/* renamed from: -deprecated_uri, reason: not valid java name */
public final URI m424deprecated_uri() {
return uri();
}
/* renamed from: -deprecated_encodedUsername, reason: not valid java name */
public final String m413deprecated_encodedUsername() {
return encodedUsername();
}
/* renamed from: -deprecated_encodedPassword, reason: not valid java name */
public final String m409deprecated_encodedPassword() {
return encodedPassword();
}
/* renamed from: -deprecated_pathSize, reason: not valid java name */
public final int m418deprecated_pathSize() {
return pathSize();
}
/* renamed from: -deprecated_encodedPath, reason: not valid java name */
public final String m410deprecated_encodedPath() {
return encodedPath();
}
/* renamed from: -deprecated_encodedPathSegments, reason: not valid java name */
public final List<String> m411deprecated_encodedPathSegments() {
return encodedPathSegments();
}
/* renamed from: -deprecated_encodedQuery, reason: not valid java name */
public final String m412deprecated_encodedQuery() {
return encodedQuery();
}
/* renamed from: -deprecated_query, reason: not valid java name */
public final String m420deprecated_query() {
return query();
}
/* renamed from: -deprecated_querySize, reason: not valid java name */
public final int m422deprecated_querySize() {
return querySize();
}
/* renamed from: -deprecated_queryParameterNames, reason: not valid java name */
public final Set<String> m421deprecated_queryParameterNames() {
return queryParameterNames();
}
/* renamed from: -deprecated_encodedFragment, reason: not valid java name */
public final String m408deprecated_encodedFragment() {
return encodedFragment();
}
/* loaded from: classes.dex */
public static final class Builder {
public static final Companion Companion = new Companion(null);
public static final String INVALID_HOST = "Invalid URL host";
private String encodedFragment;
private final List<String> encodedPathSegments;
private List<String> encodedQueryNamesAndValues;
private String host;
private String scheme;
private String encodedUsername = "";
private String encodedPassword = "";
private int port = -1;
public Builder() {
ArrayList arrayList = new ArrayList();
this.encodedPathSegments = arrayList;
arrayList.add("");
}
public final Builder scheme(String str) {
C14957gcv.e(str, "");
if (gdZ.a(str, "http", true)) {
setScheme$okhttp("http");
} else if (gdZ.a(str, "https", true)) {
setScheme$okhttp("https");
} else {
throw new IllegalArgumentException(C14957gcv.c("unexpected scheme: ", (Object) str));
}
return this;
}
public final Builder username(String str) {
C14957gcv.e(str, "");
setEncodedUsername$okhttp(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, " \"':;<=>@[]^`{}|/\\?#", false, false, false, false, null, 251, null));
return this;
}
public final Builder encodedUsername(String str) {
C14957gcv.e(str, "");
setEncodedUsername$okhttp(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, " \"':;<=>@[]^`{}|/\\?#", true, false, false, false, null, 243, null));
return this;
}
public final Builder password(String str) {
C14957gcv.e(str, "");
setEncodedPassword$okhttp(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, " \"':;<=>@[]^`{}|/\\?#", false, false, false, false, null, 251, null));
return this;
}
public final Builder encodedPassword(String str) {
C14957gcv.e(str, "");
setEncodedPassword$okhttp(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, " \"':;<=>@[]^`{}|/\\?#", true, false, false, false, null, 243, null));
return this;
}
public final Builder host(String str) {
C14957gcv.e(str, "");
String canonicalHost = HostnamesKt.toCanonicalHost(Companion.percentDecode$okhttp$default(HttpUrl.Companion, str, 0, 0, false, 7, null));
if (canonicalHost == null) {
throw new IllegalArgumentException(C14957gcv.c("unexpected host: ", (Object) str));
}
setHost$okhttp(canonicalHost);
return this;
}
public final Builder port(int i) {
if (i <= 0 || i >= 65536) {
throw new IllegalArgumentException(C14957gcv.c("unexpected port: ", Integer.valueOf(i)).toString());
}
setPort$okhttp(i);
return this;
}
private final int effectivePort() {
int i = this.port;
if (i != -1) {
return i;
}
Companion companion = HttpUrl.Companion;
String str = this.scheme;
C14957gcv.e(str);
return companion.defaultPort(str);
}
public final Builder addPathSegment(String str) {
C14957gcv.e(str, "");
push(str, 0, str.length(), false, false);
return this;
}
public final Builder addPathSegments(String str) {
C14957gcv.e(str, "");
return addPathSegments(str, false);
}
public final Builder addEncodedPathSegment(String str) {
C14957gcv.e(str, "");
push(str, 0, str.length(), false, true);
return this;
}
public final Builder addEncodedPathSegments(String str) {
C14957gcv.e(str, "");
return addPathSegments(str, true);
}
private final Builder addPathSegments(String str, boolean z) {
int i = 0;
do {
int delimiterOffset = Util.delimiterOffset(str, "/\\", i, str.length());
push(str, i, delimiterOffset, delimiterOffset < str.length(), z);
i = delimiterOffset + 1;
} while (i <= str.length());
return this;
}
public final Builder setPathSegment(int i, String str) {
C14957gcv.e(str, "");
String canonicalize$okhttp$default = Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.PATH_SEGMENT_ENCODE_SET, false, false, false, false, null, 251, null);
if (isDot(canonicalize$okhttp$default) || isDotDot(canonicalize$okhttp$default)) {
throw new IllegalArgumentException(C14957gcv.c("unexpected path segment: ", (Object) str).toString());
}
getEncodedPathSegments$okhttp().set(i, canonicalize$okhttp$default);
return this;
}
public final Builder setEncodedPathSegment(int i, String str) {
C14957gcv.e(str, "");
String canonicalize$okhttp$default = Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.PATH_SEGMENT_ENCODE_SET, true, false, false, false, null, 243, null);
getEncodedPathSegments$okhttp().set(i, canonicalize$okhttp$default);
if (isDot(canonicalize$okhttp$default) || isDotDot(canonicalize$okhttp$default)) {
throw new IllegalArgumentException(C14957gcv.c("unexpected path segment: ", (Object) str).toString());
}
return this;
}
public final Builder removePathSegment(int i) {
getEncodedPathSegments$okhttp().remove(i);
if (getEncodedPathSegments$okhttp().isEmpty()) {
getEncodedPathSegments$okhttp().add("");
}
return this;
}
public final Builder encodedPath(String str) {
C14957gcv.e(str, "");
if (!gdZ.e(str, "/", false)) {
throw new IllegalArgumentException(C14957gcv.c("unexpected encodedPath: ", (Object) str).toString());
}
resolvePath(str, 0, str.length());
return this;
}
public final Builder query(String str) {
String canonicalize$okhttp$default;
List<String> list = null;
if (str != null && (canonicalize$okhttp$default = Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.QUERY_ENCODE_SET, false, false, true, false, null, 219, null)) != null) {
list = HttpUrl.Companion.toQueryNamesAndValues$okhttp(canonicalize$okhttp$default);
}
setEncodedQueryNamesAndValues$okhttp(list);
return this;
}
public final Builder encodedQuery(String str) {
String canonicalize$okhttp$default;
List<String> list = null;
if (str != null && (canonicalize$okhttp$default = Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.QUERY_ENCODE_SET, true, false, true, false, null, Primes.SMALL_FACTOR_LIMIT, null)) != null) {
list = HttpUrl.Companion.toQueryNamesAndValues$okhttp(canonicalize$okhttp$default);
}
setEncodedQueryNamesAndValues$okhttp(list);
return this;
}
public final Builder addQueryParameter(String str, String str2) {
C14957gcv.e(str, "");
if (getEncodedQueryNamesAndValues$okhttp() == null) {
setEncodedQueryNamesAndValues$okhttp(new ArrayList());
}
List<String> encodedQueryNamesAndValues$okhttp = getEncodedQueryNamesAndValues$okhttp();
C14957gcv.e(encodedQueryNamesAndValues$okhttp);
encodedQueryNamesAndValues$okhttp.add(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.QUERY_COMPONENT_ENCODE_SET, false, false, true, false, null, 219, null));
List<String> encodedQueryNamesAndValues$okhttp2 = getEncodedQueryNamesAndValues$okhttp();
C14957gcv.e(encodedQueryNamesAndValues$okhttp2);
encodedQueryNamesAndValues$okhttp2.add(str2 == null ? null : Companion.canonicalize$okhttp$default(HttpUrl.Companion, str2, 0, 0, HttpUrl.QUERY_COMPONENT_ENCODE_SET, false, false, true, false, null, 219, null));
return this;
}
public final Builder addEncodedQueryParameter(String str, String str2) {
C14957gcv.e(str, "");
if (getEncodedQueryNamesAndValues$okhttp() == null) {
setEncodedQueryNamesAndValues$okhttp(new ArrayList());
}
List<String> encodedQueryNamesAndValues$okhttp = getEncodedQueryNamesAndValues$okhttp();
C14957gcv.e(encodedQueryNamesAndValues$okhttp);
encodedQueryNamesAndValues$okhttp.add(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.QUERY_COMPONENT_REENCODE_SET, true, false, true, false, null, Primes.SMALL_FACTOR_LIMIT, null));
List<String> encodedQueryNamesAndValues$okhttp2 = getEncodedQueryNamesAndValues$okhttp();
C14957gcv.e(encodedQueryNamesAndValues$okhttp2);
encodedQueryNamesAndValues$okhttp2.add(str2 == null ? null : Companion.canonicalize$okhttp$default(HttpUrl.Companion, str2, 0, 0, HttpUrl.QUERY_COMPONENT_REENCODE_SET, true, false, true, false, null, Primes.SMALL_FACTOR_LIMIT, null));
return this;
}
public final Builder setQueryParameter(String str, String str2) {
C14957gcv.e(str, "");
removeAllQueryParameters(str);
addQueryParameter(str, str2);
return this;
}
public final Builder setEncodedQueryParameter(String str, String str2) {
C14957gcv.e(str, "");
removeAllEncodedQueryParameters(str);
addEncodedQueryParameter(str, str2);
return this;
}
public final Builder removeAllQueryParameters(String str) {
C14957gcv.e(str, "");
if (getEncodedQueryNamesAndValues$okhttp() == null) {
return this;
}
removeAllCanonicalQueryParameters(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.QUERY_COMPONENT_ENCODE_SET, false, false, true, false, null, 219, null));
return this;
}
public final Builder removeAllEncodedQueryParameters(String str) {
C14957gcv.e(str, "");
if (getEncodedQueryNamesAndValues$okhttp() == null) {
return this;
}
removeAllCanonicalQueryParameters(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.QUERY_COMPONENT_REENCODE_SET, true, false, true, false, null, Primes.SMALL_FACTOR_LIMIT, null));
return this;
}
private final void removeAllCanonicalQueryParameters(String str) {
List<String> list = this.encodedQueryNamesAndValues;
C14957gcv.e(list);
int size = list.size() - 2;
int a = gbB.a(size, 0, -2);
if (a > size) {
return;
}
while (true) {
List<String> list2 = this.encodedQueryNamesAndValues;
C14957gcv.e(list2);
if (C14957gcv.b((Object) str, (Object) list2.get(size))) {
List<String> list3 = this.encodedQueryNamesAndValues;
C14957gcv.e(list3);
list3.remove(size + 1);
List<String> list4 = this.encodedQueryNamesAndValues;
C14957gcv.e(list4);
list4.remove(size);
List<String> list5 = this.encodedQueryNamesAndValues;
C14957gcv.e(list5);
if (list5.isEmpty()) {
this.encodedQueryNamesAndValues = null;
return;
}
}
if (size == a) {
return;
} else {
size -= 2;
}
}
}
public final Builder fragment(String str) {
setEncodedFragment$okhttp(str == null ? null : Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, "", false, false, false, true, null, org.bouncycastle.crypto.tls.CipherSuite.TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256, null));
return this;
}
public final Builder encodedFragment(String str) {
setEncodedFragment$okhttp(str == null ? null : Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, "", true, false, false, true, null, org.bouncycastle.crypto.tls.CipherSuite.TLS_DHE_PSK_WITH_AES_256_CBC_SHA384, null));
return this;
}
public final Builder reencodeForUri$okhttp() {
String host$okhttp = getHost$okhttp();
setHost$okhttp(host$okhttp == null ? null : new gdW("[\"<>^`{|}]").a(host$okhttp, ""));
int size = getEncodedPathSegments$okhttp().size();
for (int i = 0; i < size; i++) {
getEncodedPathSegments$okhttp().set(i, Companion.canonicalize$okhttp$default(HttpUrl.Companion, getEncodedPathSegments$okhttp().get(i), 0, 0, HttpUrl.PATH_SEGMENT_ENCODE_SET_URI, true, true, false, false, null, 227, null));
}
List<String> encodedQueryNamesAndValues$okhttp = getEncodedQueryNamesAndValues$okhttp();
if (encodedQueryNamesAndValues$okhttp != null) {
int size2 = encodedQueryNamesAndValues$okhttp.size();
for (int i2 = 0; i2 < size2; i2++) {
String str = encodedQueryNamesAndValues$okhttp.get(i2);
encodedQueryNamesAndValues$okhttp.set(i2, str == null ? null : Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, 0, 0, HttpUrl.QUERY_COMPONENT_ENCODE_SET_URI, true, true, true, false, null, org.bouncycastle.crypto.tls.CipherSuite.TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256, null));
}
}
String encodedFragment$okhttp = getEncodedFragment$okhttp();
setEncodedFragment$okhttp(encodedFragment$okhttp != null ? Companion.canonicalize$okhttp$default(HttpUrl.Companion, encodedFragment$okhttp, 0, 0, HttpUrl.FRAGMENT_ENCODE_SET_URI, true, true, false, true, null, org.bouncycastle.crypto.tls.CipherSuite.TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, null) : null);
return this;
}
public final HttpUrl build() {
ArrayList arrayList;
String str = this.scheme;
if (str == null) {
throw new IllegalStateException("scheme == null");
}
String percentDecode$okhttp$default = Companion.percentDecode$okhttp$default(HttpUrl.Companion, this.encodedUsername, 0, 0, false, 7, null);
String percentDecode$okhttp$default2 = Companion.percentDecode$okhttp$default(HttpUrl.Companion, this.encodedPassword, 0, 0, false, 7, null);
String str2 = this.host;
if (str2 == null) {
throw new IllegalStateException("host == null");
}
int effectivePort = effectivePort();
List<String> list = this.encodedPathSegments;
C14957gcv.e(list, "");
ArrayList arrayList2 = new ArrayList(list instanceof Collection ? list.size() : 10);
Iterator<T> it = list.iterator();
while (it.hasNext()) {
arrayList2.add(Companion.percentDecode$okhttp$default(HttpUrl.Companion, (String) it.next(), 0, 0, false, 7, null));
}
ArrayList arrayList3 = arrayList2;
List<String> list2 = this.encodedQueryNamesAndValues;
if (list2 == null) {
arrayList = null;
} else {
List<String> list3 = list2;
C14957gcv.e(list3, "");
ArrayList arrayList4 = new ArrayList(list3 instanceof Collection ? list3.size() : 10);
for (String str3 : list3) {
arrayList4.add(str3 == null ? null : Companion.percentDecode$okhttp$default(HttpUrl.Companion, str3, 0, 0, true, 3, null));
}
arrayList = arrayList4;
}
String str4 = this.encodedFragment;
return new HttpUrl(str, percentDecode$okhttp$default, percentDecode$okhttp$default2, str2, effectivePort, arrayList3, arrayList, str4 != null ? Companion.percentDecode$okhttp$default(HttpUrl.Companion, str4, 0, 0, false, 7, null) : null, toString());
}
/* JADX WARN: Code restructure failed: missing block: B:30:0x00b1, code lost:
if (r1 != r4.defaultPort(r5)) goto L28;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.lang.String toString() {
/*
r6 = this;
java.lang.StringBuilder r0 = new java.lang.StringBuilder
r0.<init>()
java.lang.String r1 = r6.getScheme$okhttp()
if (r1 == 0) goto L18
java.lang.String r1 = r6.getScheme$okhttp()
r0.append(r1)
java.lang.String r1 = "://"
r0.append(r1)
goto L1d
L18:
java.lang.String r1 = "//"
r0.append(r1)
L1d:
java.lang.String r1 = r6.getEncodedUsername$okhttp()
java.lang.CharSequence r1 = (java.lang.CharSequence) r1
int r1 = r1.length()
r2 = 58
if (r1 > 0) goto L37
java.lang.String r1 = r6.getEncodedPassword$okhttp()
java.lang.CharSequence r1 = (java.lang.CharSequence) r1
int r1 = r1.length()
if (r1 <= 0) goto L59
L37:
java.lang.String r1 = r6.getEncodedUsername$okhttp()
r0.append(r1)
java.lang.String r1 = r6.getEncodedPassword$okhttp()
java.lang.CharSequence r1 = (java.lang.CharSequence) r1
int r1 = r1.length()
if (r1 <= 0) goto L54
r0.append(r2)
java.lang.String r1 = r6.getEncodedPassword$okhttp()
r0.append(r1)
L54:
r1 = 64
r0.append(r1)
L59:
java.lang.String r1 = r6.getHost$okhttp()
java.lang.String r3 = ""
if (r1 == 0) goto L8d
java.lang.String r1 = r6.getHost$okhttp()
o.C14957gcv.e(r1)
java.lang.CharSequence r1 = (java.lang.CharSequence) r1
o.C14957gcv.e(r1, r3)
r4 = 0
int r1 = o.gdZ.a(r1, r2, r4, r4)
if (r1 < 0) goto L86
r1 = 91
r0.append(r1)
java.lang.String r1 = r6.getHost$okhttp()
r0.append(r1)
r1 = 93
r0.append(r1)
goto L8d
L86:
java.lang.String r1 = r6.getHost$okhttp()
r0.append(r1)
L8d:
int r1 = r6.getPort$okhttp()
r4 = -1
if (r1 != r4) goto L9a
java.lang.String r1 = r6.getScheme$okhttp()
if (r1 == 0) goto Lb9
L9a:
int r1 = r6.effectivePort()
java.lang.String r4 = r6.getScheme$okhttp()
if (r4 == 0) goto Lb3
okhttp3.HttpUrl$Companion r4 = okhttp3.HttpUrl.Companion
java.lang.String r5 = r6.getScheme$okhttp()
o.C14957gcv.e(r5)
int r4 = r4.defaultPort(r5)
if (r1 == r4) goto Lb9
Lb3:
r0.append(r2)
r0.append(r1)
Lb9:
okhttp3.HttpUrl$Companion r1 = okhttp3.HttpUrl.Companion
java.util.List r2 = r6.getEncodedPathSegments$okhttp()
r1.toPathString$okhttp(r2, r0)
java.util.List r1 = r6.getEncodedQueryNamesAndValues$okhttp()
if (r1 == 0) goto Ld9
r1 = 63
r0.append(r1)
okhttp3.HttpUrl$Companion r1 = okhttp3.HttpUrl.Companion
java.util.List r2 = r6.getEncodedQueryNamesAndValues$okhttp()
o.C14957gcv.e(r2)
r1.toQueryString$okhttp(r2, r0)
Ld9:
java.lang.String r1 = r6.getEncodedFragment$okhttp()
if (r1 == 0) goto Leb
r1 = 35
r0.append(r1)
java.lang.String r1 = r6.getEncodedFragment$okhttp()
r0.append(r1)
Leb:
java.lang.String r0 = r0.toString()
o.C14957gcv.c(r0, r3)
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.HttpUrl.Builder.toString():java.lang.String");
}
public final Builder parse$okhttp(HttpUrl httpUrl, String str) {
int delimiterOffset;
int i;
int i2;
boolean z;
int i3;
boolean z2;
String str2 = str;
C14957gcv.e(str2, "");
int indexOfFirstNonAsciiWhitespace$default = Util.indexOfFirstNonAsciiWhitespace$default(str2, 0, 0, 3, null);
int indexOfLastNonAsciiWhitespace$default = Util.indexOfLastNonAsciiWhitespace$default(str2, indexOfFirstNonAsciiWhitespace$default, 0, 2, null);
Companion companion = Companion;
int schemeDelimiterOffset = companion.schemeDelimiterOffset(str2, indexOfFirstNonAsciiWhitespace$default, indexOfLastNonAsciiWhitespace$default);
boolean z3 = true;
char c = 65535;
if (schemeDelimiterOffset != -1) {
if (gdZ.a(str2, "https:", indexOfFirstNonAsciiWhitespace$default, true)) {
this.scheme = "https";
indexOfFirstNonAsciiWhitespace$default += 6;
} else {
if (!gdZ.a(str2, "http:", indexOfFirstNonAsciiWhitespace$default, true)) {
StringBuilder sb = new StringBuilder("Expected URL scheme 'http' or 'https' but was '");
String substring = str2.substring(0, schemeDelimiterOffset);
C14957gcv.c((Object) substring, "");
sb.append(substring);
sb.append('\'');
throw new IllegalArgumentException(sb.toString());
}
this.scheme = "http";
indexOfFirstNonAsciiWhitespace$default += 5;
}
} else if (httpUrl != null) {
this.scheme = httpUrl.scheme();
} else {
if (str.length() > 6) {
str2 = C14957gcv.c(gdZ.b(str2, 6), (Object) "...");
}
throw new IllegalArgumentException(C14957gcv.c("Expected URL scheme 'http' or 'https' but no scheme was found for ", (Object) str2));
}
int slashCount = companion.slashCount(str2, indexOfFirstNonAsciiWhitespace$default, indexOfLastNonAsciiWhitespace$default);
char c2 = '?';
char c3 = '#';
if (slashCount < 2 && httpUrl != null && C14957gcv.b((Object) httpUrl.scheme(), (Object) this.scheme)) {
this.encodedUsername = httpUrl.encodedUsername();
this.encodedPassword = httpUrl.encodedPassword();
this.host = httpUrl.host();
this.port = httpUrl.port();
this.encodedPathSegments.clear();
this.encodedPathSegments.addAll(httpUrl.encodedPathSegments());
if (indexOfFirstNonAsciiWhitespace$default == indexOfLastNonAsciiWhitespace$default || str2.charAt(indexOfFirstNonAsciiWhitespace$default) == '#') {
encodedQuery(httpUrl.encodedQuery());
}
i = indexOfLastNonAsciiWhitespace$default;
} else {
boolean z4 = false;
boolean z5 = false;
int i4 = indexOfFirstNonAsciiWhitespace$default + slashCount;
while (true) {
delimiterOffset = Util.delimiterOffset(str2, "@/\\?#", i4, indexOfLastNonAsciiWhitespace$default);
char charAt = delimiterOffset != indexOfLastNonAsciiWhitespace$default ? str2.charAt(delimiterOffset) : c;
if (charAt == c || charAt == c3 || charAt == '/' || charAt == '\\' || charAt == c2) {
break;
}
if (charAt == '@') {
if (!z4) {
int delimiterOffset2 = Util.delimiterOffset(str2, ':', i4, delimiterOffset);
z = z3;
String canonicalize$okhttp$default = Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, i4, delimiterOffset2, " \"':;<=>@[]^`{}|/\\?#", true, false, false, false, null, 240, null);
if (z5) {
StringBuilder sb2 = new StringBuilder();
sb2.append(this.encodedUsername);
sb2.append("%40");
sb2.append(canonicalize$okhttp$default);
canonicalize$okhttp$default = sb2.toString();
}
this.encodedUsername = canonicalize$okhttp$default;
if (delimiterOffset2 != delimiterOffset) {
i2 = delimiterOffset;
this.encodedPassword = Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, delimiterOffset2 + 1, delimiterOffset, " \"':;<=>@[]^`{}|/\\?#", true, false, false, false, null, 240, null);
z2 = z;
} else {
i2 = delimiterOffset;
z2 = z4;
}
z4 = z2;
i3 = indexOfLastNonAsciiWhitespace$default;
z5 = z;
} else {
i2 = delimiterOffset;
z = z3;
StringBuilder sb3 = new StringBuilder();
sb3.append(this.encodedPassword);
sb3.append("%40");
i3 = indexOfLastNonAsciiWhitespace$default;
sb3.append(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, i4, i2, " \"':;<=>@[]^`{}|/\\?#", true, false, false, false, null, 240, null));
this.encodedPassword = sb3.toString();
}
i4 = i2 + 1;
z3 = z;
indexOfLastNonAsciiWhitespace$default = i3;
c3 = '#';
c2 = '?';
c = 65535;
}
}
i = indexOfLastNonAsciiWhitespace$default;
Companion companion2 = Companion;
int portColonOffset = companion2.portColonOffset(str2, i4, delimiterOffset);
int i5 = portColonOffset + 1;
if (i5 < delimiterOffset) {
this.host = HostnamesKt.toCanonicalHost(Companion.percentDecode$okhttp$default(HttpUrl.Companion, str, i4, portColonOffset, false, 4, null));
int parsePort = companion2.parsePort(str2, i5, delimiterOffset);
this.port = parsePort;
if (parsePort == -1) {
StringBuilder sb4 = new StringBuilder("Invalid URL port: \"");
String substring2 = str2.substring(i5, delimiterOffset);
C14957gcv.c((Object) substring2, "");
sb4.append(substring2);
sb4.append('\"');
throw new IllegalArgumentException(sb4.toString().toString());
}
} else {
this.host = HostnamesKt.toCanonicalHost(Companion.percentDecode$okhttp$default(HttpUrl.Companion, str, i4, portColonOffset, false, 4, null));
Companion companion3 = HttpUrl.Companion;
String str3 = this.scheme;
C14957gcv.e(str3);
this.port = companion3.defaultPort(str3);
}
if (this.host == null) {
StringBuilder sb5 = new StringBuilder("Invalid URL host: \"");
String substring3 = str2.substring(i4, portColonOffset);
C14957gcv.c((Object) substring3, "");
sb5.append(substring3);
sb5.append('\"');
throw new IllegalArgumentException(sb5.toString().toString());
}
indexOfFirstNonAsciiWhitespace$default = delimiterOffset;
}
int i6 = i;
int delimiterOffset3 = Util.delimiterOffset(str2, "?#", indexOfFirstNonAsciiWhitespace$default, i6);
resolvePath(str2, indexOfFirstNonAsciiWhitespace$default, delimiterOffset3);
if (delimiterOffset3 < i6 && str2.charAt(delimiterOffset3) == '?') {
int delimiterOffset4 = Util.delimiterOffset(str2, '#', delimiterOffset3, i6);
this.encodedQueryNamesAndValues = HttpUrl.Companion.toQueryNamesAndValues$okhttp(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, delimiterOffset3 + 1, delimiterOffset4, HttpUrl.QUERY_ENCODE_SET, true, false, true, false, null, 208, null));
delimiterOffset3 = delimiterOffset4;
}
if (delimiterOffset3 < i6 && str2.charAt(delimiterOffset3) == '#') {
this.encodedFragment = Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, delimiterOffset3 + 1, i6, "", true, false, false, true, null, org.bouncycastle.crypto.tls.CipherSuite.TLS_PSK_WITH_NULL_SHA256, null);
}
return this;
}
private final void resolvePath(String str, int i, int i2) {
if (i == i2) {
return;
}
char charAt = str.charAt(i);
if (charAt == '/' || charAt == '\\') {
this.encodedPathSegments.clear();
this.encodedPathSegments.add("");
i++;
} else {
List<String> list = this.encodedPathSegments;
list.set(list.size() - 1, "");
}
while (true) {
int i3 = i;
while (i3 < i2) {
i = Util.delimiterOffset(str, "/\\", i3, i2);
boolean z = i < i2;
push(str, i3, i, z, true);
if (z) {
i3 = i + 1;
}
}
return;
}
}
private final void push(String str, int i, int i2, boolean z, boolean z2) {
String canonicalize$okhttp$default = Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, i, i2, HttpUrl.PATH_SEGMENT_ENCODE_SET, z2, false, false, false, null, 240, null);
if (isDot(canonicalize$okhttp$default)) {
return;
}
if (isDotDot(canonicalize$okhttp$default)) {
pop();
return;
}
if (this.encodedPathSegments.get(r2.size() - 1).length() == 0) {
this.encodedPathSegments.set(r2.size() - 1, canonicalize$okhttp$default);
} else {
this.encodedPathSegments.add(canonicalize$okhttp$default);
}
if (z) {
this.encodedPathSegments.add("");
}
}
private final boolean isDot(String str) {
return C14957gcv.b((Object) str, (Object) ".") || gdZ.a(str, "%2e", true);
}
private final boolean isDotDot(String str) {
return C14957gcv.b((Object) str, (Object) "..") || gdZ.a(str, "%2e.", true) || gdZ.a(str, ".%2e", true) || gdZ.a(str, "%2e%2e", true);
}
private final void pop() {
if (this.encodedPathSegments.remove(r0.size() - 1).length() == 0 && (!this.encodedPathSegments.isEmpty())) {
this.encodedPathSegments.set(r0.size() - 1, "");
} else {
this.encodedPathSegments.add("");
}
}
/* loaded from: classes.dex */
public static final class Companion {
private Companion() {
}
/* JADX INFO: Access modifiers changed from: private */
public final int schemeDelimiterOffset(String str, int i, int i2) {
if (i2 - i < 2) {
return -1;
}
char charAt = str.charAt(i);
if ((C14957gcv.a(charAt, 97) < 0 || C14957gcv.a(charAt, 122) > 0) && (C14957gcv.a(charAt, 65) < 0 || C14957gcv.a(charAt, 90) > 0)) {
return -1;
}
while (true) {
i++;
if (i >= i2) {
return -1;
}
char charAt2 = str.charAt(i);
if ('a' > charAt2 || charAt2 >= '{') {
if ('A' > charAt2 || charAt2 >= '[') {
if ('0' > charAt2 || charAt2 >= ':') {
if (charAt2 != '+' && charAt2 != '-' && charAt2 != '.') {
if (charAt2 == ':') {
return i;
}
return -1;
}
}
}
}
}
}
/* JADX INFO: Access modifiers changed from: private */
public final int slashCount(String str, int i, int i2) {
int i3 = 0;
while (i < i2) {
char charAt = str.charAt(i);
if (charAt != '\\' && charAt != '/') {
break;
}
i3++;
i++;
}
return i3;
}
/* JADX INFO: Access modifiers changed from: private */
public final int portColonOffset(String str, int i, int i2) {
while (i < i2) {
char charAt = str.charAt(i);
if (charAt != '[') {
if (charAt == ':') {
return i;
}
i++;
}
do {
i++;
if (i < i2) {
}
i++;
} while (str.charAt(i) != ']');
i++;
}
return i2;
}
/* JADX INFO: Access modifiers changed from: private */
public final int parsePort(String str, int i, int i2) {
try {
int parseInt = Integer.parseInt(Companion.canonicalize$okhttp$default(HttpUrl.Companion, str, i, i2, "", false, false, false, false, null, 248, null));
if (parseInt <= 0 || parseInt >= 65536) {
return -1;
}
return parseInt;
} catch (NumberFormatException unused) {
return -1;
}
}
public /* synthetic */ Companion(C14953gcr c14953gcr) {
this();
}
}
public final void setScheme$okhttp(String str) {
this.scheme = str;
}
public final void setPort$okhttp(int i) {
this.port = i;
}
public final void setHost$okhttp(String str) {
this.host = str;
}
public final void setEncodedUsername$okhttp(String str) {
C14957gcv.e(str, "");
this.encodedUsername = str;
}
public final void setEncodedQueryNamesAndValues$okhttp(List<String> list) {
this.encodedQueryNamesAndValues = list;
}
public final void setEncodedPassword$okhttp(String str) {
C14957gcv.e(str, "");
this.encodedPassword = str;
}
public final void setEncodedFragment$okhttp(String str) {
this.encodedFragment = str;
}
public final String getScheme$okhttp() {
return this.scheme;
}
public final int getPort$okhttp() {
return this.port;
}
public final String getHost$okhttp() {
return this.host;
}
public final String getEncodedUsername$okhttp() {
return this.encodedUsername;
}
public final List<String> getEncodedQueryNamesAndValues$okhttp() {
return this.encodedQueryNamesAndValues;
}
public final List<String> getEncodedPathSegments$okhttp() {
return this.encodedPathSegments;
}
public final String getEncodedPassword$okhttp() {
return this.encodedPassword;
}
public final String getEncodedFragment$okhttp() {
return this.encodedFragment;
}
}
/* loaded from: classes.dex */
public static final class Companion {
private Companion() {
}
public final int defaultPort(String str) {
C14957gcv.e(str, "");
if (C14957gcv.b((Object) str, (Object) "http")) {
return 80;
}
if (C14957gcv.b((Object) str, (Object) "https")) {
return GrpcUtil.DEFAULT_PORT_SSL;
}
return -1;
}
public final void toPathString$okhttp(List<String> list, StringBuilder sb) {
C14957gcv.e(list, "");
C14957gcv.e(sb, "");
int size = list.size();
for (int i = 0; i < size; i++) {
sb.append('/');
sb.append(list.get(i));
}
}
public final void toQueryString$okhttp(List<String> list, StringBuilder sb) {
C14973gde c14973gde;
C14957gcv.e(list, "");
C14957gcv.e(sb, "");
int size = list.size();
if (size <= Integer.MIN_VALUE) {
C14973gde.LWm lWm = C14973gde.c;
c14973gde = C14973gde.f;
} else {
c14973gde = new C14973gde(0, size - 1);
}
C14969gda b = C14977gdi.b(c14973gde, 2);
int i = b.b;
int i2 = b.d;
int i3 = b.e;
if ((i3 <= 0 || i > i2) && (i3 >= 0 || i2 > i)) {
return;
}
while (true) {
String str = list.get(i);
String str2 = list.get(i + 1);
if (i > 0) {
sb.append('&');
}
sb.append(str);
if (str2 != null) {
sb.append('=');
sb.append(str2);
}
if (i == i2) {
return;
} else {
i += i3;
}
}
}
public final List<String> toQueryNamesAndValues$okhttp(String str) {
C14957gcv.e(str, "");
ArrayList arrayList = new ArrayList();
int i = 0;
while (i <= str.length()) {
String str2 = str;
int a = gdZ.a((CharSequence) str2, '&', i, false);
if (a == -1) {
a = str.length();
}
int a2 = gdZ.a((CharSequence) str2, '=', i, false);
if (a2 == -1 || a2 > a) {
String substring = str.substring(i, a);
C14957gcv.c((Object) substring, "");
arrayList.add(substring);
arrayList.add(null);
} else {
String substring2 = str.substring(i, a2);
C14957gcv.c((Object) substring2, "");
arrayList.add(substring2);
String substring3 = str.substring(a2 + 1, a);
C14957gcv.c((Object) substring3, "");
arrayList.add(substring3);
}
i = a + 1;
}
return arrayList;
}
public final HttpUrl get(String str) {
C14957gcv.e(str, "");
return new Builder().parse$okhttp(null, str).build();
}
public final HttpUrl parse(String str) {
C14957gcv.e(str, "");
try {
return get(str);
} catch (IllegalArgumentException unused) {
return null;
}
}
public final HttpUrl get(URL url) {
C14957gcv.e(url, "");
String obj = url.toString();
C14957gcv.c((Object) obj, "");
return parse(obj);
}
public final HttpUrl get(URI uri) {
C14957gcv.e(uri, "");
String obj = uri.toString();
C14957gcv.c((Object) obj, "");
return parse(obj);
}
/* renamed from: -deprecated_get, reason: not valid java name */
public final HttpUrl m427deprecated_get(String str) {
C14957gcv.e(str, "");
return get(str);
}
/* renamed from: -deprecated_parse, reason: not valid java name */
public final HttpUrl m430deprecated_parse(String str) {
C14957gcv.e(str, "");
return parse(str);
}
/* renamed from: -deprecated_get, reason: not valid java name */
public final HttpUrl m429deprecated_get(URL url) {
C14957gcv.e(url, "");
return get(url);
}
/* renamed from: -deprecated_get, reason: not valid java name */
public final HttpUrl m428deprecated_get(URI uri) {
C14957gcv.e(uri, "");
return get(uri);
}
public static /* synthetic */ String percentDecode$okhttp$default(Companion companion, String str, int i, int i2, boolean z, int i3, Object obj) {
if ((i3 & 1) != 0) {
i = 0;
}
if ((i3 & 2) != 0) {
i2 = str.length();
}
if ((i3 & 4) != 0) {
z = false;
}
return companion.percentDecode$okhttp(str, i, i2, z);
}
public final String percentDecode$okhttp(String str, int i, int i2, boolean z) {
C14957gcv.e(str, "");
for (int i3 = i; i3 < i2; i3++) {
char charAt = str.charAt(i3);
if (charAt == '%' || (charAt == '+' && z)) {
C15111ghZ c15111ghZ = new C15111ghZ();
c15111ghZ.c(str, i, i3);
writePercentDecoded(c15111ghZ, str, i3, i2, z);
return c15111ghZ.b(c15111ghZ.c, gdP.a);
}
}
String substring = str.substring(i, i2);
C14957gcv.c((Object) substring, "");
return substring;
}
private final void writePercentDecoded(C15111ghZ c15111ghZ, String str, int i, int i2, boolean z) {
int i3;
while (i < i2) {
int codePointAt = str.codePointAt(i);
if (codePointAt == 37 && (i3 = i + 2) < i2) {
int parseHexDigit = Util.parseHexDigit(str.charAt(i + 1));
int parseHexDigit2 = Util.parseHexDigit(str.charAt(i3));
if (parseHexDigit != -1 && parseHexDigit2 != -1) {
c15111ghZ.b((parseHexDigit << 4) + parseHexDigit2);
i = Character.charCount(codePointAt) + i3;
}
c15111ghZ.i(codePointAt);
i += Character.charCount(codePointAt);
} else {
if (codePointAt == 43 && z) {
c15111ghZ.b(32);
i++;
}
c15111ghZ.i(codePointAt);
i += Character.charCount(codePointAt);
}
}
}
private final boolean isPercentEncoded(String str, int i, int i2) {
int i3 = i + 2;
return i3 < i2 && str.charAt(i) == '%' && Util.parseHexDigit(str.charAt(i + 1)) != -1 && Util.parseHexDigit(str.charAt(i3)) != -1;
}
public static /* synthetic */ String canonicalize$okhttp$default(Companion companion, String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset, int i3, Object obj) {
return companion.canonicalize$okhttp(str, (i3 & 1) != 0 ? 0 : i, (i3 & 2) != 0 ? str.length() : i2, str2, (i3 & 8) != 0 ? false : z, (i3 & 16) != 0 ? false : z2, (i3 & 32) != 0 ? false : z3, (i3 & 64) != 0 ? false : z4, (i3 & 128) != 0 ? null : charset);
}
public final String canonicalize$okhttp(String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset) {
C14957gcv.e(str, "");
C14957gcv.e(str2, "");
int i3 = i;
while (i3 < i2) {
int codePointAt = str.codePointAt(i3);
if (codePointAt >= 32 && codePointAt != 127 && (codePointAt < 128 || z4)) {
String str3 = str2;
C14957gcv.e(str3, "");
if (gdZ.a((CharSequence) str3, (char) codePointAt, 0, false) < 0) {
if (codePointAt == 37) {
if (z) {
if (z2) {
if (!isPercentEncoded(str, i3, i2)) {
C15111ghZ c15111ghZ = new C15111ghZ();
c15111ghZ.c(str, i, i3);
writeCanonicalized(c15111ghZ, str, i3, i2, str2, z, z2, z3, z4, charset);
return c15111ghZ.b(c15111ghZ.c, gdP.a);
}
if (codePointAt != 43 && z3) {
C15111ghZ c15111ghZ2 = new C15111ghZ();
c15111ghZ2.c(str, i, i3);
writeCanonicalized(c15111ghZ2, str, i3, i2, str2, z, z2, z3, z4, charset);
return c15111ghZ2.b(c15111ghZ2.c, gdP.a);
}
i3 += Character.charCount(codePointAt);
}
}
}
if (codePointAt != 43) {
}
i3 += Character.charCount(codePointAt);
}
}
C15111ghZ c15111ghZ22 = new C15111ghZ();
c15111ghZ22.c(str, i, i3);
writeCanonicalized(c15111ghZ22, str, i3, i2, str2, z, z2, z3, z4, charset);
return c15111ghZ22.b(c15111ghZ22.c, gdP.a);
}
String substring = str.substring(i, i2);
C14957gcv.c((Object) substring, "");
return substring;
}
/* JADX WARN: Code restructure failed: missing block: B:36:0x006a, code lost:
if (isPercentEncoded(r15, r4, r17) != false) goto L39;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private final void writeCanonicalized(o.C15111ghZ r14, java.lang.String r15, int r16, int r17, java.lang.String r18, boolean r19, boolean r20, boolean r21, boolean r22, java.nio.charset.Charset r23) {
/*
r13 = this;
r0 = r14
r1 = r15
r2 = r17
r3 = r23
r4 = 0
r5 = r4
r4 = r16
La:
if (r4 >= r2) goto Lc1
int r6 = r15.codePointAt(r4)
if (r19 == 0) goto L25
r7 = 9
if (r6 == r7) goto L22
r7 = 10
if (r6 == r7) goto L22
r7 = 12
if (r6 == r7) goto L22
r7 = 13
if (r6 != r7) goto L25
L22:
r7 = r13
goto L98
L25:
r7 = 43
java.lang.String r8 = ""
r9 = 0
if (r6 != r7) goto L40
if (r21 == 0) goto L40
if (r19 == 0) goto L33
java.lang.String r7 = "+"
goto L35
L33:
java.lang.String r7 = "%2B"
L35:
o.C14957gcv.e(r7, r8)
int r8 = r7.length()
r14.c(r7, r9, r8)
goto L22
L40:
r7 = 32
r10 = 37
if (r6 < r7) goto L72
r7 = 127(0x7f, float:1.78E-43)
if (r6 == r7) goto L72
r7 = 128(0x80, float:1.8E-43)
if (r6 < r7) goto L50
if (r22 == 0) goto L72
L50:
r7 = r18
java.lang.CharSequence r7 = (java.lang.CharSequence) r7
char r11 = (char) r6
o.C14957gcv.e(r7, r8)
int r7 = o.gdZ.a(r7, r11, r9, r9)
if (r7 < 0) goto L5f
goto L72
L5f:
if (r6 != r10) goto L6d
if (r19 == 0) goto L72
if (r20 == 0) goto L6d
r7 = r13
boolean r8 = r13.isPercentEncoded(r15, r4, r2)
if (r8 == 0) goto L73
goto L6e
L6d:
r7 = r13
L6e:
r14.i(r6)
goto L98
L72:
r7 = r13
L73:
if (r5 != 0) goto L7a
o.ghZ r5 = new o.ghZ
r5.<init>()
L7a:
if (r3 == 0) goto L8d
java.nio.charset.Charset r8 = java.nio.charset.StandardCharsets.UTF_8
boolean r8 = o.C14957gcv.b(r3, r8)
if (r8 != 0) goto L8d
int r8 = java.lang.Character.charCount(r6)
int r8 = r8 + r4
r5.d(r15, r4, r8, r3)
goto L90
L8d:
r5.i(r6)
L90:
long r8 = r5.c
r11 = 0
int r8 = (r8 > r11 ? 1 : (r8 == r11 ? 0 : -1))
if (r8 != 0) goto L9f
L98:
int r6 = java.lang.Character.charCount(r6)
int r4 = r4 + r6
goto La
L9f:
byte r8 = r5.f()
r14.b(r10)
char[] r9 = okhttp3.HttpUrl.access$getHEX_DIGITS$cp()
r11 = r8 & 255(0xff, float:3.57E-43)
int r11 = r11 >> 4
r11 = r11 & 15
char r9 = r9[r11]
r14.b(r9)
char[] r9 = okhttp3.HttpUrl.access$getHEX_DIGITS$cp()
r8 = r8 & 15
char r8 = r9[r8]
r14.b(r8)
goto L90
Lc1:
r7 = r13
return
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.HttpUrl.Companion.writeCanonicalized(o.ghZ, java.lang.String, int, int, java.lang.String, boolean, boolean, boolean, boolean, java.nio.charset.Charset):void");
}
public /* synthetic */ Companion(C14953gcr c14953gcr) {
this();
}
}
public final Set<String> queryParameterNames() {
C14973gde c14973gde;
if (this.queryNamesAndValues != null) {
LinkedHashSet linkedHashSet = new LinkedHashSet();
int size = this.queryNamesAndValues.size();
if (size <= Integer.MIN_VALUE) {
C14973gde.LWm lWm = C14973gde.c;
c14973gde = C14973gde.f;
} else {
c14973gde = new C14973gde(0, size - 1);
}
C14969gda b = C14977gdi.b(c14973gde, 2);
int i = b.b;
int i2 = b.d;
int i3 = b.e;
if ((i3 > 0 && i <= i2) || (i3 < 0 && i2 <= i)) {
while (true) {
String str = this.queryNamesAndValues.get(i);
C14957gcv.e(str);
linkedHashSet.add(str);
if (i == i2) {
break;
}
i += i3;
}
}
Set<String> unmodifiableSet = Collections.unmodifiableSet(linkedHashSet);
C14957gcv.c(unmodifiableSet, "");
return unmodifiableSet;
}
return gaH.e;
}
public final List<String> queryParameterValues(String str) {
C14973gde c14973gde;
C14957gcv.e(str, "");
if (this.queryNamesAndValues != null) {
ArrayList arrayList = new ArrayList();
int size = this.queryNamesAndValues.size();
if (size <= Integer.MIN_VALUE) {
C14973gde.LWm lWm = C14973gde.c;
c14973gde = C14973gde.f;
} else {
c14973gde = new C14973gde(0, size - 1);
}
C14969gda b = C14977gdi.b(c14973gde, 2);
int i = b.b;
int i2 = b.d;
int i3 = b.e;
if ((i3 > 0 && i <= i2) || (i3 < 0 && i2 <= i)) {
while (true) {
if (C14957gcv.b((Object) str, (Object) this.queryNamesAndValues.get(i))) {
arrayList.add(this.queryNamesAndValues.get(i + 1));
}
if (i == i2) {
break;
}
i += i3;
}
}
List<String> unmodifiableList = Collections.unmodifiableList(arrayList);
C14957gcv.c(unmodifiableList, "");
return unmodifiableList;
}
return C14851gaI.c;
}
public final String username() {
return this.username;
}
public final String toString() {
return this.url;
}
public final String scheme() {
return this.scheme;
}
public final int port() {
return this.port;
}
public final List<String> pathSegments() {
return this.pathSegments;
}
public final String password() {
return this.password;
}
public final boolean isHttps() {
return this.isHttps;
}
public final String host() {
return this.host;
}
public final String fragment() {
return this.fragment;
}
/* renamed from: -deprecated_username, reason: not valid java name */
public final String m426deprecated_username() {
return this.username;
}
/* renamed from: -deprecated_scheme, reason: not valid java name */
public final String m423deprecated_scheme() {
return this.scheme;
}
/* renamed from: -deprecated_port, reason: not valid java name */
public final int m419deprecated_port() {
return this.port;
}
/* renamed from: -deprecated_pathSegments, reason: not valid java name */
public final List<String> m417deprecated_pathSegments() {
return this.pathSegments;
}
/* renamed from: -deprecated_password, reason: not valid java name */
public final String m416deprecated_password() {
return this.password;
}
/* renamed from: -deprecated_host, reason: not valid java name */
public final String m415deprecated_host() {
return this.host;
}
/* renamed from: -deprecated_fragment, reason: not valid java name */
public final String m414deprecated_fragment() {
return this.fragment;
}
public static final HttpUrl parse(String str) {
return Companion.parse(str);
}
public static final HttpUrl get(URL url) {
return Companion.get(url);
}
public static final HttpUrl get(URI uri) {
return Companion.get(uri);
}
public static final HttpUrl get(String str) {
return Companion.get(str);
}
public static final int defaultPort(String str) {
return Companion.defaultPort(str);
}
}