what-the-bank/sources/com/google/android/gms/internal/firebase_ml/zzfx.java

82 lines
3.1 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.firebase_ml;
import com.google.common.net.HttpHeaders;
import io.grpc.internal.GrpcUtil;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
/* loaded from: classes2.dex */
final class zzfx extends zzfp {
private final HttpURLConnection zzvy;
/* JADX INFO: Access modifiers changed from: package-private */
public zzfx(HttpURLConnection httpURLConnection) {
this.zzvy = httpURLConnection;
httpURLConnection.setInstanceFollowRedirects(false);
}
@Override // com.google.android.gms.internal.firebase_ml.zzfp
public final void addHeader(String str, String str2) {
this.zzvy.addRequestProperty(str, str2);
}
@Override // com.google.android.gms.internal.firebase_ml.zzfp
public final void zza(int i, int i2) {
this.zzvy.setReadTimeout(i2);
this.zzvy.setConnectTimeout(i);
}
@Override // com.google.android.gms.internal.firebase_ml.zzfp
public final zzfq zzfo() throws IOException {
HttpURLConnection httpURLConnection = this.zzvy;
if (zzfn() != null) {
String contentType = getContentType();
if (contentType != null) {
addHeader(HttpHeaders.CONTENT_TYPE, contentType);
}
String contentEncoding = getContentEncoding();
if (contentEncoding != null) {
addHeader(HttpHeaders.CONTENT_ENCODING, contentEncoding);
}
long contentLength = getContentLength();
if (contentLength >= 0) {
httpURLConnection.setRequestProperty(HttpHeaders.CONTENT_LENGTH, Long.toString(contentLength));
}
String requestMethod = httpURLConnection.getRequestMethod();
if (GrpcUtil.HTTP_METHOD.equals(requestMethod) || "PUT".equals(requestMethod)) {
httpURLConnection.setDoOutput(true);
if (contentLength >= 0 && contentLength <= 2147483647L) {
httpURLConnection.setFixedLengthStreamingMode((int) contentLength);
} else {
httpURLConnection.setChunkedStreamingMode(0);
}
OutputStream outputStream = httpURLConnection.getOutputStream();
try {
zzfn().writeTo(outputStream);
outputStream.close();
} catch (Throwable th) {
try {
outputStream.close();
} catch (IOException unused) {
}
throw th;
}
} else {
boolean z = contentLength == 0;
Object[] objArr = {requestMethod};
if (!z) {
throw new IllegalArgumentException(zzla.zzb("%s with non-zero content length is not supported", objArr));
}
}
}
try {
httpURLConnection.connect();
return new zzfy(httpURLConnection);
} catch (Throwable th2) {
httpURLConnection.disconnect();
throw th2;
}
}
}