218 lines
7.3 KiB
Java
218 lines
7.3 KiB
Java
package okhttp3;
|
|
|
|
import androidx.browser.trusted.sharing.ShareTarget;
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
|
import d0.g0.t;
|
|
import d0.t.h0;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
import f0.d;
|
|
import f0.e0.c;
|
|
import f0.e0.h.f;
|
|
import f0.w;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import kotlin.Pair;
|
|
import okhttp3.Headers;
|
|
/* compiled from: Request.kt */
|
|
/* loaded from: classes3.dex */
|
|
public final class Request {
|
|
public d a;
|
|
|
|
/* renamed from: b reason: collision with root package name */
|
|
public final w f3785b;
|
|
public final String c;
|
|
public final Headers d;
|
|
public final RequestBody e;
|
|
public final Map<Class<?>, Object> f;
|
|
|
|
/* compiled from: Request.kt */
|
|
/* loaded from: classes3.dex */
|
|
public static class a {
|
|
public w a;
|
|
|
|
/* renamed from: b reason: collision with root package name */
|
|
public String f3786b;
|
|
public Headers.a c;
|
|
public RequestBody d;
|
|
public Map<Class<?>, Object> e;
|
|
|
|
public a() {
|
|
this.e = new LinkedHashMap();
|
|
this.f3786b = ShareTarget.METHOD_GET;
|
|
this.c = new Headers.a();
|
|
}
|
|
|
|
public a(Request request) {
|
|
m.checkParameterIsNotNull(request, "request");
|
|
this.e = new LinkedHashMap();
|
|
this.a = request.f3785b;
|
|
this.f3786b = request.c;
|
|
this.d = request.e;
|
|
this.e = request.f.isEmpty() ? new LinkedHashMap<>() : h0.toMutableMap(request.f);
|
|
this.c = request.d.e();
|
|
}
|
|
|
|
public Request a() {
|
|
w wVar = this.a;
|
|
if (wVar != null) {
|
|
return new Request(wVar, this.f3786b, this.c.c(), this.d, c.A(this.e));
|
|
}
|
|
throw new IllegalStateException("url == null".toString());
|
|
}
|
|
|
|
public a b(String str, String str2) {
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
m.checkParameterIsNotNull(str2, "value");
|
|
Headers.a aVar = this.c;
|
|
Objects.requireNonNull(aVar);
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
m.checkParameterIsNotNull(str2, "value");
|
|
Headers.b bVar = Headers.j;
|
|
bVar.a(str);
|
|
bVar.b(str2, str);
|
|
aVar.d(str);
|
|
aVar.b(str, str2);
|
|
return this;
|
|
}
|
|
|
|
public a c(String str, RequestBody requestBody) {
|
|
m.checkParameterIsNotNull(str, "method");
|
|
boolean z2 = false;
|
|
if (str.length() > 0) {
|
|
if (requestBody == null) {
|
|
m.checkParameterIsNotNull(str, "method");
|
|
if (m.areEqual(str, ShareTarget.METHOD_POST) || m.areEqual(str, "PUT") || m.areEqual(str, "PATCH") || m.areEqual(str, "PROPPATCH") || m.areEqual(str, "REPORT")) {
|
|
z2 = true;
|
|
}
|
|
if (!(!z2)) {
|
|
throw new IllegalArgumentException(b.d.b.a.a.w("method ", str, " must have a request body.").toString());
|
|
}
|
|
} else if (!f.a(str)) {
|
|
throw new IllegalArgumentException(b.d.b.a.a.w("method ", str, " must not have a request body.").toString());
|
|
}
|
|
this.f3786b = str;
|
|
this.d = requestBody;
|
|
return this;
|
|
}
|
|
throw new IllegalArgumentException("method.isEmpty() == true".toString());
|
|
}
|
|
|
|
public a d(String str) {
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
this.c.d(str);
|
|
return this;
|
|
}
|
|
|
|
public <T> a e(Class<? super T> cls, T t) {
|
|
m.checkParameterIsNotNull(cls, "type");
|
|
if (t == null) {
|
|
this.e.remove(cls);
|
|
} else {
|
|
if (this.e.isEmpty()) {
|
|
this.e = new LinkedHashMap();
|
|
}
|
|
Map<Class<?>, Object> map = this.e;
|
|
Object cast = cls.cast(t);
|
|
if (cast == null) {
|
|
m.throwNpe();
|
|
}
|
|
map.put(cls, cast);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public a f(String str) {
|
|
m.checkParameterIsNotNull(str, "url");
|
|
if (t.startsWith(str, "ws:", true)) {
|
|
StringBuilder R = b.d.b.a.a.R("http:");
|
|
String substring = str.substring(3);
|
|
m.checkExpressionValueIsNotNull(substring, "(this as java.lang.String).substring(startIndex)");
|
|
R.append(substring);
|
|
str = R.toString();
|
|
} else if (t.startsWith(str, "wss:", true)) {
|
|
StringBuilder R2 = b.d.b.a.a.R("https:");
|
|
String substring2 = str.substring(4);
|
|
m.checkExpressionValueIsNotNull(substring2, "(this as java.lang.String).substring(startIndex)");
|
|
R2.append(substring2);
|
|
str = R2.toString();
|
|
}
|
|
m.checkParameterIsNotNull(str, "$this$toHttpUrl");
|
|
w.a aVar = new w.a();
|
|
aVar.e(null, str);
|
|
g(aVar.b());
|
|
return this;
|
|
}
|
|
|
|
public a g(w wVar) {
|
|
m.checkParameterIsNotNull(wVar, "url");
|
|
this.a = wVar;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public Request(w wVar, String str, Headers headers, RequestBody requestBody, Map<Class<?>, ? extends Object> map) {
|
|
m.checkParameterIsNotNull(wVar, "url");
|
|
m.checkParameterIsNotNull(str, "method");
|
|
m.checkParameterIsNotNull(headers, "headers");
|
|
m.checkParameterIsNotNull(map, ModelAuditLogEntry.CHANGE_KEY_TAGS);
|
|
this.f3785b = wVar;
|
|
this.c = str;
|
|
this.d = headers;
|
|
this.e = requestBody;
|
|
this.f = map;
|
|
}
|
|
|
|
public final d a() {
|
|
d dVar = this.a;
|
|
if (dVar != null) {
|
|
return dVar;
|
|
}
|
|
d b2 = d.a.b(this.d);
|
|
this.a = b2;
|
|
return b2;
|
|
}
|
|
|
|
public final String b(String str) {
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
return this.d.c(str);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = b.d.b.a.a.R("Request{method=");
|
|
R.append(this.c);
|
|
R.append(", url=");
|
|
R.append(this.f3785b);
|
|
if (this.d.size() != 0) {
|
|
R.append(", headers=[");
|
|
int i = 0;
|
|
for (Pair<? extends String, ? extends String> pair : this.d) {
|
|
i++;
|
|
if (i < 0) {
|
|
n.throwIndexOverflow();
|
|
}
|
|
Pair<? extends String, ? extends String> pair2 = pair;
|
|
String str = (String) pair2.component1();
|
|
String str2 = (String) pair2.component2();
|
|
if (i > 0) {
|
|
R.append(", ");
|
|
}
|
|
R.append(str);
|
|
R.append(MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR);
|
|
R.append(str2);
|
|
}
|
|
R.append(']');
|
|
}
|
|
if (!this.f.isEmpty()) {
|
|
R.append(", tags=");
|
|
R.append(this.f);
|
|
}
|
|
R.append('}');
|
|
String sb = R.toString();
|
|
m.checkExpressionValueIsNotNull(sb, "StringBuilder().apply(builderAction).toString()");
|
|
return sb;
|
|
}
|
|
}
|