132 lines
4.7 KiB
Java
132 lines
4.7 KiB
Java
package com.google.android.gms.auth.api.proxy;
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.util.Patterns;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
|
|
import com.google.android.gms.common.internal.safeparcel.SafeParcelWriter;
|
|
import java.util.Collections;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ProxyRequest extends AbstractSafeParcelable {
|
|
public static final int VERSION_CODE = 2;
|
|
public final byte[] body;
|
|
public final int httpMethod;
|
|
public final long timeoutMillis;
|
|
public final String url;
|
|
private final int versionCode;
|
|
private Bundle zzby;
|
|
public static final Parcelable.Creator<ProxyRequest> CREATOR = new zza();
|
|
public static final int HTTP_METHOD_GET = 0;
|
|
public static final int HTTP_METHOD_POST = 1;
|
|
public static final int HTTP_METHOD_PUT = 2;
|
|
public static final int HTTP_METHOD_DELETE = 3;
|
|
public static final int HTTP_METHOD_HEAD = 4;
|
|
public static final int HTTP_METHOD_OPTIONS = 5;
|
|
public static final int HTTP_METHOD_TRACE = 6;
|
|
public static final int HTTP_METHOD_PATCH = 7;
|
|
public static final int LAST_CODE = 7;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public ProxyRequest(int i, String str, int i2, long j, byte[] bArr, Bundle bundle) {
|
|
this.versionCode = i;
|
|
this.url = str;
|
|
this.httpMethod = i2;
|
|
this.timeoutMillis = j;
|
|
this.body = bArr;
|
|
this.zzby = bundle;
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class Builder {
|
|
private String zzbz;
|
|
private int zzca = ProxyRequest.HTTP_METHOD_GET;
|
|
private long zzcb = 3000;
|
|
private byte[] zzcc = null;
|
|
private Bundle zzcd = new Bundle();
|
|
|
|
public Builder(String str) {
|
|
Preconditions.checkNotEmpty(str);
|
|
if (Patterns.WEB_URL.matcher(str).matches()) {
|
|
this.zzbz = str;
|
|
return;
|
|
}
|
|
StringBuilder sb = new StringBuilder(String.valueOf(str).length() + 51);
|
|
sb.append("The supplied url [ ");
|
|
sb.append(str);
|
|
sb.append("] is not match Patterns.WEB_URL!");
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
|
|
public Builder setHttpMethod(int i) {
|
|
Preconditions.checkArgument(i >= 0 && i <= ProxyRequest.LAST_CODE, "Unrecognized http method code.");
|
|
this.zzca = i;
|
|
return this;
|
|
}
|
|
|
|
public Builder setTimeoutMillis(long j) {
|
|
Preconditions.checkArgument(j >= 0, "The specified timeout must be non-negative.");
|
|
this.zzcb = j;
|
|
return this;
|
|
}
|
|
|
|
public Builder putHeader(String str, String str2) {
|
|
Preconditions.checkNotEmpty(str, "Header name cannot be null or empty!");
|
|
Bundle bundle = this.zzcd;
|
|
if (str2 == null) {
|
|
str2 = "";
|
|
}
|
|
bundle.putString(str, str2);
|
|
return this;
|
|
}
|
|
|
|
public ProxyRequest build() {
|
|
if (this.zzcc == null) {
|
|
this.zzcc = new byte[0];
|
|
}
|
|
return new ProxyRequest(2, this.zzbz, this.zzca, this.zzcb, this.zzcc, this.zzcd);
|
|
}
|
|
|
|
public Builder setBody(byte[] bArr) {
|
|
this.zzcc = bArr;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public Map<String, String> getHeaderMap() {
|
|
LinkedHashMap linkedHashMap = new LinkedHashMap(this.zzby.size());
|
|
for (String str : this.zzby.keySet()) {
|
|
linkedHashMap.put(str, this.zzby.getString(str));
|
|
}
|
|
return Collections.unmodifiableMap(linkedHashMap);
|
|
}
|
|
|
|
public String toString() {
|
|
String str = this.url;
|
|
int i = this.httpMethod;
|
|
StringBuilder sb = new StringBuilder(String.valueOf(str).length() + 42);
|
|
sb.append("ProxyRequest[ url: ");
|
|
sb.append(str);
|
|
sb.append(", method: ");
|
|
sb.append(i);
|
|
sb.append(" ]");
|
|
return sb.toString();
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
int beginObjectHeader = SafeParcelWriter.beginObjectHeader(parcel);
|
|
SafeParcelWriter.writeString(parcel, 1, this.url, false);
|
|
SafeParcelWriter.writeInt(parcel, 2, this.httpMethod);
|
|
SafeParcelWriter.writeLong(parcel, 3, this.timeoutMillis);
|
|
SafeParcelWriter.writeByteArray(parcel, 4, this.body, false);
|
|
SafeParcelWriter.writeBundle(parcel, 5, this.zzby, false);
|
|
SafeParcelWriter.writeInt(parcel, 1000, this.versionCode);
|
|
SafeParcelWriter.finishObjectHeader(parcel, beginObjectHeader);
|
|
}
|
|
}
|