Files
rr3-apk/decompiled-community/sources/okhttp3/internal/http/BridgeInterceptor.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

91 lines
3.5 KiB
Java

package okhttp3.internal.http;
import com.ironsource.nb;
import com.mbridge.msdk.foundation.download.Command;
import java.util.List;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.internal.Util;
import okhttp3.internal.Version;
import okio.GzipSource;
import okio.Okio;
import org.apache.http.cookie.SM;
import org.apache.http.protocol.HTTP;
/* loaded from: classes5.dex */
public final class BridgeInterceptor implements Interceptor {
public final CookieJar cookieJar;
public BridgeInterceptor(CookieJar cookieJar) {
this.cookieJar = cookieJar;
}
@Override // okhttp3.Interceptor
public Response intercept(Interceptor.Chain chain) {
Request request = chain.request();
Request.Builder newBuilder = request.newBuilder();
RequestBody body = request.body();
if (body != null) {
MediaType contentType = body.contentType();
if (contentType != null) {
newBuilder.header("Content-Type", contentType.toString());
}
long contentLength = body.contentLength();
if (contentLength != -1) {
newBuilder.header(HTTP.CONTENT_LEN, Long.toString(contentLength));
newBuilder.removeHeader(HTTP.TRANSFER_ENCODING);
} else {
newBuilder.header(HTTP.TRANSFER_ENCODING, HTTP.CHUNK_CODING);
newBuilder.removeHeader(HTTP.CONTENT_LEN);
}
}
boolean z = false;
if (request.header(HTTP.TARGET_HOST) == null) {
newBuilder.header(HTTP.TARGET_HOST, Util.hostHeader(request.url(), false));
}
if (request.header(HTTP.CONN_DIRECTIVE) == null) {
newBuilder.header(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
}
if (request.header("Accept-Encoding") == null && request.header(Command.HTTP_HEADER_RANGE) == null) {
newBuilder.header("Accept-Encoding", "gzip");
z = true;
}
List loadForRequest = this.cookieJar.loadForRequest(request.url());
if (!loadForRequest.isEmpty()) {
newBuilder.header(SM.COOKIE, cookieHeader(loadForRequest));
}
if (request.header("User-Agent") == null) {
newBuilder.header("User-Agent", Version.userAgent());
}
Response proceed = chain.proceed(newBuilder.build());
HttpHeaders.receiveHeaders(this.cookieJar, request.url(), proceed.headers());
Response.Builder request2 = proceed.newBuilder().request(request);
if (z && "gzip".equalsIgnoreCase(proceed.header(HTTP.CONTENT_ENCODING)) && HttpHeaders.hasBody(proceed)) {
GzipSource gzipSource = new GzipSource(proceed.body().source());
request2.headers(proceed.headers().newBuilder().removeAll(HTTP.CONTENT_ENCODING).removeAll(HTTP.CONTENT_LEN).build());
request2.body(new RealResponseBody(proceed.header("Content-Type"), -1L, Okio.buffer(gzipSource)));
}
return request2.build();
}
public final String cookieHeader(List list) {
StringBuilder sb = new StringBuilder();
int size = list.size();
for (int i = 0; i < size; i++) {
if (i > 0) {
sb.append("; ");
}
Cookie cookie = (Cookie) list.get(i);
sb.append(cookie.name());
sb.append(nb.T);
sb.append(cookie.value());
}
return sb.toString();
}
}