386 lines
12 KiB
Java
386 lines
12 KiB
Java
|
package okhttp3;
|
||
|
|
||
|
import com.airbnb.deeplinkdispatch.UrlTreeKt;
|
||
|
import com.google.common.net.HttpHeaders;
|
||
|
import io.grpc.internal.GrpcUtil;
|
||
|
import java.net.URL;
|
||
|
import java.util.LinkedHashMap;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import o.C13396fZU;
|
||
|
import o.C14957gcv;
|
||
|
import o.gdZ;
|
||
|
import okhttp3.Headers;
|
||
|
import okhttp3.HttpUrl;
|
||
|
import okhttp3.internal.Util;
|
||
|
import okhttp3.internal.http.HttpMethod;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class Request {
|
||
|
private final RequestBody body;
|
||
|
private final Headers headers;
|
||
|
private CacheControl lazyCacheControl;
|
||
|
private final String method;
|
||
|
private final Map<Class<?>, Object> tags;
|
||
|
private final HttpUrl url;
|
||
|
|
||
|
public Request(HttpUrl httpUrl, String str, Headers headers, RequestBody requestBody, Map<Class<?>, ? extends Object> map) {
|
||
|
C14957gcv.e(httpUrl, "");
|
||
|
C14957gcv.e(str, "");
|
||
|
C14957gcv.e(headers, "");
|
||
|
C14957gcv.e(map, "");
|
||
|
this.url = httpUrl;
|
||
|
this.method = str;
|
||
|
this.headers = headers;
|
||
|
this.body = requestBody;
|
||
|
this.tags = map;
|
||
|
}
|
||
|
|
||
|
public final boolean isHttps() {
|
||
|
return this.url.isHttps();
|
||
|
}
|
||
|
|
||
|
public final String header(String str) {
|
||
|
C14957gcv.e(str, "");
|
||
|
return this.headers.get(str);
|
||
|
}
|
||
|
|
||
|
public final List<String> headers(String str) {
|
||
|
C14957gcv.e(str, "");
|
||
|
return this.headers.values(str);
|
||
|
}
|
||
|
|
||
|
public final Object tag() {
|
||
|
return tag(Object.class);
|
||
|
}
|
||
|
|
||
|
public final <T> T tag(Class<? extends T> cls) {
|
||
|
C14957gcv.e(cls, "");
|
||
|
return cls.cast(this.tags.get(cls));
|
||
|
}
|
||
|
|
||
|
public final Builder newBuilder() {
|
||
|
return new Builder(this);
|
||
|
}
|
||
|
|
||
|
public final CacheControl cacheControl() {
|
||
|
CacheControl cacheControl = this.lazyCacheControl;
|
||
|
if (cacheControl != null) {
|
||
|
return cacheControl;
|
||
|
}
|
||
|
CacheControl parse = CacheControl.Companion.parse(this.headers);
|
||
|
this.lazyCacheControl = parse;
|
||
|
return parse;
|
||
|
}
|
||
|
|
||
|
/* renamed from: -deprecated_cacheControl, reason: not valid java name */
|
||
|
public final CacheControl m470deprecated_cacheControl() {
|
||
|
return cacheControl();
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
public final String toString() {
|
||
|
StringBuilder sb = new StringBuilder("Request{method=");
|
||
|
sb.append(method());
|
||
|
sb.append(", url=");
|
||
|
sb.append(url());
|
||
|
if (headers().size() != 0) {
|
||
|
sb.append(", headers=[");
|
||
|
int i = 0;
|
||
|
for (C13396fZU<? extends String, ? extends String> c13396fZU : headers()) {
|
||
|
if (i >= 0) {
|
||
|
C13396fZU<? extends String, ? extends String> c13396fZU2 = c13396fZU;
|
||
|
String str = (String) c13396fZU2.d;
|
||
|
String str2 = (String) c13396fZU2.e;
|
||
|
if (i > 0) {
|
||
|
sb.append(", ");
|
||
|
}
|
||
|
sb.append(str);
|
||
|
sb.append(':');
|
||
|
sb.append(str2);
|
||
|
i++;
|
||
|
} else {
|
||
|
throw new ArithmeticException("Index overflow has happened.");
|
||
|
}
|
||
|
}
|
||
|
sb.append(']');
|
||
|
}
|
||
|
if (!getTags$okhttp().isEmpty()) {
|
||
|
sb.append(", tags=");
|
||
|
sb.append(getTags$okhttp());
|
||
|
}
|
||
|
sb.append(UrlTreeKt.componentParamSuffixChar);
|
||
|
String obj = sb.toString();
|
||
|
C14957gcv.c((Object) obj, "");
|
||
|
return obj;
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public static class Builder {
|
||
|
private RequestBody body;
|
||
|
private Headers.Builder headers;
|
||
|
private String method;
|
||
|
private Map<Class<?>, Object> tags;
|
||
|
private HttpUrl url;
|
||
|
|
||
|
public Builder() {
|
||
|
this.tags = new LinkedHashMap();
|
||
|
this.method = "GET";
|
||
|
this.headers = new Headers.Builder();
|
||
|
}
|
||
|
|
||
|
public Builder(Request request) {
|
||
|
LinkedHashMap linkedHashMap;
|
||
|
C14957gcv.e(request, "");
|
||
|
this.tags = new LinkedHashMap();
|
||
|
this.url = request.url();
|
||
|
this.method = request.method();
|
||
|
this.body = request.body();
|
||
|
if (request.getTags$okhttp().isEmpty()) {
|
||
|
linkedHashMap = new LinkedHashMap();
|
||
|
} else {
|
||
|
Map<Class<?>, Object> tags$okhttp = request.getTags$okhttp();
|
||
|
C14957gcv.e(tags$okhttp, "");
|
||
|
linkedHashMap = new LinkedHashMap(tags$okhttp);
|
||
|
}
|
||
|
this.tags = linkedHashMap;
|
||
|
this.headers = request.headers().newBuilder();
|
||
|
}
|
||
|
|
||
|
public Builder url(HttpUrl httpUrl) {
|
||
|
C14957gcv.e(httpUrl, "");
|
||
|
setUrl$okhttp(httpUrl);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder url(String str) {
|
||
|
C14957gcv.e(str, "");
|
||
|
if (gdZ.e(str, "ws:", true)) {
|
||
|
String substring = str.substring(3);
|
||
|
C14957gcv.c((Object) substring, "");
|
||
|
str = C14957gcv.c("http:", (Object) substring);
|
||
|
} else if (gdZ.e(str, "wss:", true)) {
|
||
|
String substring2 = str.substring(4);
|
||
|
C14957gcv.c((Object) substring2, "");
|
||
|
str = C14957gcv.c("https:", (Object) substring2);
|
||
|
}
|
||
|
return url(HttpUrl.Companion.get(str));
|
||
|
}
|
||
|
|
||
|
public Builder url(URL url) {
|
||
|
C14957gcv.e(url, "");
|
||
|
HttpUrl.Companion companion = HttpUrl.Companion;
|
||
|
String obj = url.toString();
|
||
|
C14957gcv.c((Object) obj, "");
|
||
|
return url(companion.get(obj));
|
||
|
}
|
||
|
|
||
|
public Builder header(String str, String str2) {
|
||
|
C14957gcv.e(str, "");
|
||
|
C14957gcv.e(str2, "");
|
||
|
getHeaders$okhttp().set(str, str2);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder addHeader(String str, String str2) {
|
||
|
C14957gcv.e(str, "");
|
||
|
C14957gcv.e(str2, "");
|
||
|
getHeaders$okhttp().add(str, str2);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder removeHeader(String str) {
|
||
|
C14957gcv.e(str, "");
|
||
|
getHeaders$okhttp().removeAll(str);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder headers(Headers headers) {
|
||
|
C14957gcv.e(headers, "");
|
||
|
setHeaders$okhttp(headers.newBuilder());
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder cacheControl(CacheControl cacheControl) {
|
||
|
C14957gcv.e(cacheControl, "");
|
||
|
String obj = cacheControl.toString();
|
||
|
return obj.length() == 0 ? removeHeader(HttpHeaders.CACHE_CONTROL) : header(HttpHeaders.CACHE_CONTROL, obj);
|
||
|
}
|
||
|
|
||
|
public Builder get() {
|
||
|
return method("GET", null);
|
||
|
}
|
||
|
|
||
|
public Builder head() {
|
||
|
return method("HEAD", null);
|
||
|
}
|
||
|
|
||
|
public Builder post(RequestBody requestBody) {
|
||
|
C14957gcv.e(requestBody, "");
|
||
|
return method(GrpcUtil.HTTP_METHOD, requestBody);
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ Builder delete$default(Builder builder, RequestBody requestBody, int i, Object obj) {
|
||
|
if (obj != null) {
|
||
|
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: delete");
|
||
|
}
|
||
|
if ((i & 1) != 0) {
|
||
|
requestBody = Util.EMPTY_REQUEST;
|
||
|
}
|
||
|
return builder.delete(requestBody);
|
||
|
}
|
||
|
|
||
|
public Builder delete(RequestBody requestBody) {
|
||
|
return method("DELETE", requestBody);
|
||
|
}
|
||
|
|
||
|
public Builder put(RequestBody requestBody) {
|
||
|
C14957gcv.e(requestBody, "");
|
||
|
return method("PUT", requestBody);
|
||
|
}
|
||
|
|
||
|
public Builder patch(RequestBody requestBody) {
|
||
|
C14957gcv.e(requestBody, "");
|
||
|
return method("PATCH", requestBody);
|
||
|
}
|
||
|
|
||
|
public Builder method(String str, RequestBody requestBody) {
|
||
|
C14957gcv.e(str, "");
|
||
|
if (str.length() <= 0) {
|
||
|
throw new IllegalArgumentException("method.isEmpty() == true".toString());
|
||
|
}
|
||
|
if (requestBody == null) {
|
||
|
if (!(!HttpMethod.requiresRequestBody(str))) {
|
||
|
StringBuilder sb = new StringBuilder("method ");
|
||
|
sb.append(str);
|
||
|
sb.append(" must have a request body.");
|
||
|
throw new IllegalArgumentException(sb.toString().toString());
|
||
|
}
|
||
|
} else if (!HttpMethod.permitsRequestBody(str)) {
|
||
|
StringBuilder sb2 = new StringBuilder("method ");
|
||
|
sb2.append(str);
|
||
|
sb2.append(" must not have a request body.");
|
||
|
throw new IllegalArgumentException(sb2.toString().toString());
|
||
|
}
|
||
|
setMethod$okhttp(str);
|
||
|
setBody$okhttp(requestBody);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder tag(Object obj) {
|
||
|
return tag(Object.class, obj);
|
||
|
}
|
||
|
|
||
|
public <T> Builder tag(Class<? super T> cls, T t) {
|
||
|
C14957gcv.e(cls, "");
|
||
|
if (t == null) {
|
||
|
getTags$okhttp().remove(cls);
|
||
|
} else {
|
||
|
if (getTags$okhttp().isEmpty()) {
|
||
|
setTags$okhttp(new LinkedHashMap());
|
||
|
}
|
||
|
Map<Class<?>, Object> tags$okhttp = getTags$okhttp();
|
||
|
T cast = cls.cast(t);
|
||
|
C14957gcv.e(cast);
|
||
|
tags$okhttp.put(cls, cast);
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Request build() {
|
||
|
HttpUrl httpUrl = this.url;
|
||
|
if (httpUrl != null) {
|
||
|
return new Request(httpUrl, this.method, this.headers.build(), this.body, Util.toImmutableMap(this.tags));
|
||
|
}
|
||
|
throw new IllegalStateException("url == null".toString());
|
||
|
}
|
||
|
|
||
|
public final void setUrl$okhttp(HttpUrl httpUrl) {
|
||
|
this.url = httpUrl;
|
||
|
}
|
||
|
|
||
|
public final void setTags$okhttp(Map<Class<?>, Object> map) {
|
||
|
C14957gcv.e(map, "");
|
||
|
this.tags = map;
|
||
|
}
|
||
|
|
||
|
public final void setMethod$okhttp(String str) {
|
||
|
C14957gcv.e(str, "");
|
||
|
this.method = str;
|
||
|
}
|
||
|
|
||
|
public final void setHeaders$okhttp(Headers.Builder builder) {
|
||
|
C14957gcv.e(builder, "");
|
||
|
this.headers = builder;
|
||
|
}
|
||
|
|
||
|
public final void setBody$okhttp(RequestBody requestBody) {
|
||
|
this.body = requestBody;
|
||
|
}
|
||
|
|
||
|
public final HttpUrl getUrl$okhttp() {
|
||
|
return this.url;
|
||
|
}
|
||
|
|
||
|
public final Map<Class<?>, Object> getTags$okhttp() {
|
||
|
return this.tags;
|
||
|
}
|
||
|
|
||
|
public final String getMethod$okhttp() {
|
||
|
return this.method;
|
||
|
}
|
||
|
|
||
|
public final Headers.Builder getHeaders$okhttp() {
|
||
|
return this.headers;
|
||
|
}
|
||
|
|
||
|
public final RequestBody getBody$okhttp() {
|
||
|
return this.body;
|
||
|
}
|
||
|
|
||
|
public final Builder delete() {
|
||
|
return delete$default(this, null, 1, null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final HttpUrl url() {
|
||
|
return this.url;
|
||
|
}
|
||
|
|
||
|
public final String method() {
|
||
|
return this.method;
|
||
|
}
|
||
|
|
||
|
public final Headers headers() {
|
||
|
return this.headers;
|
||
|
}
|
||
|
|
||
|
public final Map<Class<?>, Object> getTags$okhttp() {
|
||
|
return this.tags;
|
||
|
}
|
||
|
|
||
|
public final RequestBody body() {
|
||
|
return this.body;
|
||
|
}
|
||
|
|
||
|
/* renamed from: -deprecated_url, reason: not valid java name */
|
||
|
public final HttpUrl m473deprecated_url() {
|
||
|
return this.url;
|
||
|
}
|
||
|
|
||
|
/* renamed from: -deprecated_method, reason: not valid java name */
|
||
|
public final String m472deprecated_method() {
|
||
|
return this.method;
|
||
|
}
|
||
|
|
||
|
/* renamed from: -deprecated_headers, reason: not valid java name */
|
||
|
public final Headers m471deprecated_headers() {
|
||
|
return this.headers;
|
||
|
}
|
||
|
|
||
|
/* renamed from: -deprecated_body, reason: not valid java name */
|
||
|
public final RequestBody m469deprecated_body() {
|
||
|
return this.body;
|
||
|
}
|
||
|
}
|