2021-08-24 17:45:16 +00:00
|
|
|
package okhttp3;
|
|
|
|
|
|
|
|
import androidx.browser.trusted.sharing.ShareTarget;
|
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
|
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
2021-11-08 18:25:28 +00:00
|
|
|
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;
|
2021-08-24 17:45:16 +00:00
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Objects;
|
|
|
|
import kotlin.Pair;
|
|
|
|
import okhttp3.Headers;
|
|
|
|
/* compiled from: Request.kt */
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-24 17:45:16 +00:00
|
|
|
public final class Request {
|
|
|
|
public d a;
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
2022-03-30 16:43:10 +00:00
|
|
|
public final w f3794b;
|
2021-12-21 23:37:30 +00:00
|
|
|
public final String c;
|
2021-08-24 17:45:16 +00:00
|
|
|
public final Headers d;
|
|
|
|
public final RequestBody e;
|
|
|
|
public final Map<Class<?>, Object> f;
|
|
|
|
|
|
|
|
/* compiled from: Request.kt */
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-24 17:45:16 +00:00
|
|
|
public static class a {
|
|
|
|
public w a;
|
|
|
|
|
2021-12-21 23:37:30 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
2022-03-30 16:43:10 +00:00
|
|
|
public String f3795b;
|
2021-12-21 23:37:30 +00:00
|
|
|
public Headers.a c;
|
2021-08-24 17:45:16 +00:00
|
|
|
public RequestBody d;
|
|
|
|
public Map<Class<?>, Object> e;
|
|
|
|
|
|
|
|
public a() {
|
|
|
|
this.e = new LinkedHashMap();
|
2022-03-30 16:43:10 +00:00
|
|
|
this.f3795b = ShareTarget.METHOD_GET;
|
2021-12-21 23:37:30 +00:00
|
|
|
this.c = new Headers.a();
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public a(Request request) {
|
|
|
|
m.checkParameterIsNotNull(request, "request");
|
|
|
|
this.e = new LinkedHashMap();
|
2022-03-30 16:43:10 +00:00
|
|
|
this.a = request.f3794b;
|
|
|
|
this.f3795b = request.c;
|
2021-08-24 17:45:16 +00:00
|
|
|
this.d = request.e;
|
|
|
|
this.e = request.f.isEmpty() ? new LinkedHashMap<>() : h0.toMutableMap(request.f);
|
2021-12-21 23:37:30 +00:00
|
|
|
this.c = request.d.e();
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Request a() {
|
|
|
|
w wVar = this.a;
|
|
|
|
if (wVar != null) {
|
2022-03-30 16:43:10 +00:00
|
|
|
return new Request(wVar, this.f3795b, this.c.c(), this.d, c.A(this.e));
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
|
|
|
throw new IllegalStateException("url == null".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public a b(String str, String str2) {
|
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
|
|
m.checkParameterIsNotNull(str2, "value");
|
2021-12-21 23:37:30 +00:00
|
|
|
Headers.a aVar = this.c;
|
2021-08-24 17:45:16 +00:00
|
|
|
Objects.requireNonNull(aVar);
|
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
|
|
m.checkParameterIsNotNull(str2, "value");
|
2021-12-17 22:03:14 +00:00
|
|
|
Headers.b bVar = Headers.j;
|
2021-08-24 17:45:16 +00:00
|
|
|
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)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
throw new IllegalArgumentException(b.d.b.a.a.w("method ", str, " must have a request body.").toString());
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
|
|
|
} else if (!f.a(str)) {
|
2021-12-21 23:37:30 +00:00
|
|
|
throw new IllegalArgumentException(b.d.b.a.a.w("method ", str, " must not have a request body.").toString());
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
2022-03-30 16:43:10 +00:00
|
|
|
this.f3795b = str;
|
2021-08-24 17:45:16 +00:00
|
|
|
this.d = requestBody;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
throw new IllegalArgumentException("method.isEmpty() == true".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public a d(String str) {
|
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-12-21 23:37:30 +00:00
|
|
|
this.c.d(str);
|
2021-08-24 17:45:16 +00:00
|
|
|
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)) {
|
2022-03-30 16:43:10 +00:00
|
|
|
StringBuilder R = b.d.b.a.a.R("http:");
|
2021-08-24 17:45:16 +00:00
|
|
|
String substring = str.substring(3);
|
|
|
|
m.checkExpressionValueIsNotNull(substring, "(this as java.lang.String).substring(startIndex)");
|
2022-03-30 16:43:10 +00:00
|
|
|
R.append(substring);
|
|
|
|
str = R.toString();
|
2021-08-24 17:45:16 +00:00
|
|
|
} else if (t.startsWith(str, "wss:", true)) {
|
2022-03-30 16:43:10 +00:00
|
|
|
StringBuilder R2 = b.d.b.a.a.R("https:");
|
2021-08-24 17:45:16 +00:00
|
|
|
String substring2 = str.substring(4);
|
|
|
|
m.checkExpressionValueIsNotNull(substring2, "(this as java.lang.String).substring(startIndex)");
|
2022-03-30 16:43:10 +00:00
|
|
|
R2.append(substring2);
|
|
|
|
str = R2.toString();
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
|
|
|
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);
|
2022-03-30 16:43:10 +00:00
|
|
|
this.f3794b = wVar;
|
2021-12-21 23:37:30 +00:00
|
|
|
this.c = str;
|
2021-08-24 17:45:16 +00:00
|
|
|
this.d = headers;
|
|
|
|
this.e = requestBody;
|
|
|
|
this.f = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final d a() {
|
|
|
|
d dVar = this.a;
|
|
|
|
if (dVar != null) {
|
|
|
|
return dVar;
|
|
|
|
}
|
2021-12-21 23:37:30 +00:00
|
|
|
d b2 = d.a.b(this.d);
|
|
|
|
this.a = b2;
|
|
|
|
return b2;
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final String b(String str) {
|
|
|
|
m.checkParameterIsNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
|
|
return this.d.c(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2022-03-30 16:43:10 +00:00
|
|
|
StringBuilder R = b.d.b.a.a.R("Request{method=");
|
|
|
|
R.append(this.c);
|
|
|
|
R.append(", url=");
|
|
|
|
R.append(this.f3794b);
|
2021-08-24 17:45:16 +00:00
|
|
|
if (this.d.size() != 0) {
|
2022-03-30 16:43:10 +00:00
|
|
|
R.append(", headers=[");
|
2021-08-24 17:45:16 +00:00
|
|
|
int i = 0;
|
|
|
|
for (Pair<? extends String, ? extends String> pair : this.d) {
|
2022-03-02 20:59:20 +00:00
|
|
|
i++;
|
2021-08-24 17:45:16 +00:00
|
|
|
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) {
|
2022-03-30 16:43:10 +00:00
|
|
|
R.append(", ");
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
2022-03-30 16:43:10 +00:00
|
|
|
R.append(str);
|
|
|
|
R.append(MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR);
|
|
|
|
R.append(str2);
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
2022-03-30 16:43:10 +00:00
|
|
|
R.append(']');
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
|
|
|
if (!this.f.isEmpty()) {
|
2022-03-30 16:43:10 +00:00
|
|
|
R.append(", tags=");
|
|
|
|
R.append(this.f);
|
2021-08-24 17:45:16 +00:00
|
|
|
}
|
2022-03-30 16:43:10 +00:00
|
|
|
R.append('}');
|
|
|
|
String sb = R.toString();
|
2021-08-24 17:45:16 +00:00
|
|
|
m.checkExpressionValueIsNotNull(sb, "StringBuilder().apply(builderAction).toString()");
|
|
|
|
return sb;
|
|
|
|
}
|
|
|
|
}
|