276 lines
10 KiB
Java
276 lines
10 KiB
Java
package f0.g0;
|
|
|
|
import d0.g0.t;
|
|
import d0.t.n0;
|
|
import d0.z.d.m;
|
|
import f0.f0.g.j;
|
|
import f0.f0.h.g;
|
|
import f0.k;
|
|
import f0.z;
|
|
import g0.e;
|
|
import g0.l;
|
|
import java.io.IOException;
|
|
import java.nio.charset.Charset;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.Set;
|
|
import java.util.concurrent.TimeUnit;
|
|
import okhttp3.Headers;
|
|
import okhttp3.Interceptor;
|
|
import okhttp3.MediaType;
|
|
import okhttp3.RequestBody;
|
|
import okhttp3.Response;
|
|
import okhttp3.ResponseBody;
|
|
/* compiled from: HttpLoggingInterceptor.kt */
|
|
public final class a implements Interceptor {
|
|
public volatile Set<String> b = n0.emptySet();
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public volatile EnumC0310a f2771c = EnumC0310a.NONE;
|
|
public final b d;
|
|
|
|
/* compiled from: HttpLoggingInterceptor.kt */
|
|
/* renamed from: f0.g0.a$a reason: collision with other inner class name */
|
|
public enum EnumC0310a {
|
|
NONE,
|
|
BASIC,
|
|
HEADERS,
|
|
BODY
|
|
}
|
|
|
|
/* compiled from: HttpLoggingInterceptor.kt */
|
|
public interface b {
|
|
void log(String str);
|
|
}
|
|
|
|
public a(b bVar) {
|
|
m.checkParameterIsNotNull(bVar, "logger");
|
|
this.d = bVar;
|
|
}
|
|
|
|
public final boolean a(Headers headers) {
|
|
String c2 = headers.c("Content-Encoding");
|
|
return c2 != null && !t.equals(c2, "identity", true) && !t.equals(c2, "gzip", true);
|
|
}
|
|
|
|
public final void b(Headers headers, int i) {
|
|
int i2 = i * 2;
|
|
String str = this.b.contains(headers.j[i2]) ? "██" : headers.j[i2 + 1];
|
|
b bVar = this.d;
|
|
bVar.log(headers.j[i2] + ": " + str);
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:102:0x02e4, code lost:
|
|
r0 = move-exception;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:103:0x02e5, code lost:
|
|
d0.y.b.closeFinally(r6, r0);
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:104:0x02e9, code lost:
|
|
throw r0;
|
|
*/
|
|
@Override // okhttp3.Interceptor
|
|
public Response intercept(Interceptor.Chain chain) throws IOException {
|
|
String str;
|
|
String str2;
|
|
String str3;
|
|
Charset charset;
|
|
Charset charset2;
|
|
m.checkParameterIsNotNull(chain, "chain");
|
|
EnumC0310a aVar = this.f2771c;
|
|
g gVar = (g) chain;
|
|
z zVar = gVar.f;
|
|
if (aVar == EnumC0310a.NONE) {
|
|
return gVar.a(zVar);
|
|
}
|
|
boolean z2 = aVar == EnumC0310a.BODY;
|
|
boolean z3 = z2 || aVar == EnumC0310a.HEADERS;
|
|
RequestBody requestBody = zVar.e;
|
|
k b2 = gVar.b();
|
|
StringBuilder K = c.d.b.a.a.K("--> ");
|
|
K.append(zVar.f2792c);
|
|
K.append(' ');
|
|
K.append(zVar.b);
|
|
if (b2 != null) {
|
|
StringBuilder K2 = c.d.b.a.a.K(" ");
|
|
K2.append(((j) b2).m());
|
|
str = K2.toString();
|
|
} else {
|
|
str = "";
|
|
}
|
|
K.append(str);
|
|
String sb = K.toString();
|
|
if (!z3 && requestBody != null) {
|
|
StringBuilder O = c.d.b.a.a.O(sb, " (");
|
|
O.append(requestBody.contentLength());
|
|
O.append("-byte body)");
|
|
sb = O.toString();
|
|
}
|
|
this.d.log(sb);
|
|
if (z3) {
|
|
Headers headers = zVar.d;
|
|
if (requestBody != null) {
|
|
MediaType contentType = requestBody.contentType();
|
|
if (contentType != null && headers.c("Content-Type") == null) {
|
|
this.d.log("Content-Type: " + contentType);
|
|
}
|
|
if (requestBody.contentLength() != -1 && headers.c("Content-Length") == null) {
|
|
b bVar = this.d;
|
|
StringBuilder K3 = c.d.b.a.a.K("Content-Length: ");
|
|
K3.append(requestBody.contentLength());
|
|
bVar.log(K3.toString());
|
|
}
|
|
}
|
|
int size = headers.size();
|
|
for (int i = 0; i < size; i++) {
|
|
b(headers, i);
|
|
}
|
|
if (!z2 || requestBody == null) {
|
|
b bVar2 = this.d;
|
|
StringBuilder K4 = c.d.b.a.a.K("--> END ");
|
|
K4.append(zVar.f2792c);
|
|
bVar2.log(K4.toString());
|
|
} else if (a(zVar.d)) {
|
|
b bVar3 = this.d;
|
|
StringBuilder K5 = c.d.b.a.a.K("--> END ");
|
|
K5.append(zVar.f2792c);
|
|
K5.append(" (encoded body omitted)");
|
|
bVar3.log(K5.toString());
|
|
} else if (requestBody.isDuplex()) {
|
|
b bVar4 = this.d;
|
|
StringBuilder K6 = c.d.b.a.a.K("--> END ");
|
|
K6.append(zVar.f2792c);
|
|
K6.append(" (duplex request body omitted)");
|
|
bVar4.log(K6.toString());
|
|
} else if (requestBody.isOneShot()) {
|
|
b bVar5 = this.d;
|
|
StringBuilder K7 = c.d.b.a.a.K("--> END ");
|
|
K7.append(zVar.f2792c);
|
|
K7.append(" (one-shot body omitted)");
|
|
bVar5.log(K7.toString());
|
|
} else {
|
|
e eVar = new e();
|
|
requestBody.writeTo(eVar);
|
|
MediaType contentType2 = requestBody.contentType();
|
|
if (contentType2 == null || (charset2 = contentType2.a(StandardCharsets.UTF_8)) == null) {
|
|
charset2 = StandardCharsets.UTF_8;
|
|
m.checkExpressionValueIsNotNull(charset2, "UTF_8");
|
|
}
|
|
this.d.log("");
|
|
if (c.q.a.k.a.E(eVar)) {
|
|
this.d.log(eVar.L(charset2));
|
|
b bVar6 = this.d;
|
|
StringBuilder K8 = c.d.b.a.a.K("--> END ");
|
|
K8.append(zVar.f2792c);
|
|
K8.append(" (");
|
|
K8.append(requestBody.contentLength());
|
|
K8.append("-byte body)");
|
|
bVar6.log(K8.toString());
|
|
} else {
|
|
b bVar7 = this.d;
|
|
StringBuilder K9 = c.d.b.a.a.K("--> END ");
|
|
K9.append(zVar.f2792c);
|
|
K9.append(" (binary ");
|
|
K9.append(requestBody.contentLength());
|
|
K9.append("-byte body omitted)");
|
|
bVar7.log(K9.toString());
|
|
}
|
|
}
|
|
}
|
|
long nanoTime = System.nanoTime();
|
|
try {
|
|
Response a = gVar.a(zVar);
|
|
long millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - nanoTime);
|
|
ResponseBody responseBody = a.o;
|
|
if (responseBody == null) {
|
|
m.throwNpe();
|
|
}
|
|
long a2 = responseBody.a();
|
|
String str4 = a2 != -1 ? a2 + "-byte" : "unknown-length";
|
|
b bVar8 = this.d;
|
|
StringBuilder K10 = c.d.b.a.a.K("<-- ");
|
|
K10.append(a.l);
|
|
if (a.k.length() == 0) {
|
|
str2 = "-byte body omitted)";
|
|
str3 = "";
|
|
} else {
|
|
String str5 = a.k;
|
|
StringBuilder sb2 = new StringBuilder();
|
|
str2 = "-byte body omitted)";
|
|
sb2.append(String.valueOf(' '));
|
|
sb2.append(str5);
|
|
str3 = sb2.toString();
|
|
}
|
|
K10.append(str3);
|
|
K10.append(' ');
|
|
K10.append(a.i.b);
|
|
K10.append(" (");
|
|
K10.append(millis);
|
|
K10.append("ms");
|
|
K10.append(!z3 ? c.d.b.a.a.t(", ", str4, " body") : "");
|
|
K10.append(')');
|
|
bVar8.log(K10.toString());
|
|
if (z3) {
|
|
Headers headers2 = a.n;
|
|
int size2 = headers2.size();
|
|
for (int i2 = 0; i2 < size2; i2++) {
|
|
b(headers2, i2);
|
|
}
|
|
if (!z2 || !f0.f0.h.e.a(a)) {
|
|
this.d.log("<-- END HTTP");
|
|
} else if (a(a.n)) {
|
|
this.d.log("<-- END HTTP (encoded body omitted)");
|
|
} else {
|
|
g0.g c2 = responseBody.c();
|
|
c2.j(Long.MAX_VALUE);
|
|
e g = c2.g();
|
|
Long l = null;
|
|
if (t.equals("gzip", headers2.c("Content-Encoding"), true)) {
|
|
Long valueOf = Long.valueOf(g.j);
|
|
l lVar = new l(g.clone());
|
|
g = new e();
|
|
g.O(lVar);
|
|
d0.y.b.closeFinally(lVar, null);
|
|
l = valueOf;
|
|
}
|
|
MediaType b3 = responseBody.b();
|
|
if (b3 == null || (charset = b3.a(StandardCharsets.UTF_8)) == null) {
|
|
charset = StandardCharsets.UTF_8;
|
|
m.checkExpressionValueIsNotNull(charset, "UTF_8");
|
|
}
|
|
if (!c.q.a.k.a.E(g)) {
|
|
this.d.log("");
|
|
b bVar9 = this.d;
|
|
StringBuilder K11 = c.d.b.a.a.K("<-- END HTTP (binary ");
|
|
K11.append(g.j);
|
|
K11.append(str2);
|
|
bVar9.log(K11.toString());
|
|
return a;
|
|
}
|
|
if (a2 != 0) {
|
|
this.d.log("");
|
|
this.d.log(g.clone().L(charset));
|
|
}
|
|
if (l != null) {
|
|
b bVar10 = this.d;
|
|
StringBuilder K12 = c.d.b.a.a.K("<-- END HTTP (");
|
|
K12.append(g.j);
|
|
K12.append("-byte, ");
|
|
K12.append(l);
|
|
K12.append("-gzipped-byte body)");
|
|
bVar10.log(K12.toString());
|
|
} else {
|
|
b bVar11 = this.d;
|
|
StringBuilder K13 = c.d.b.a.a.K("<-- END HTTP (");
|
|
K13.append(g.j);
|
|
K13.append("-byte body)");
|
|
bVar11.log(K13.toString());
|
|
}
|
|
}
|
|
}
|
|
return a;
|
|
} catch (Exception e) {
|
|
this.d.log("<-- HTTP FAILED: " + e);
|
|
throw e;
|
|
}
|
|
}
|
|
}
|