discord-jadx/app/src/main/java/c/i/a/f/i/b/d7.java

60 lines
2.0 KiB
Java

package c.i.a.f.i.b;
import androidx.annotation.WorkerThread;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class d7 extends r5 {
public d7(u4 u4Var) {
super(u4Var);
}
public static byte[] t(HttpURLConnection httpURLConnection) throws IOException {
InputStream inputStream = null;
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
InputStream inputStream2 = httpURLConnection.getInputStream();
byte[] bArr = new byte[1024];
while (true) {
int read = inputStream2.read(bArr);
if (read > 0) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
byte[] byteArray = byteArrayOutputStream.toByteArray();
inputStream2.close();
return byteArray;
}
}
} catch (Throwable th) {
if (0 != 0) {
inputStream.close();
}
throw th;
}
}
@Override // c.i.a.f.i.b.r5
public final boolean r() {
return false;
}
@WorkerThread
public final HttpURLConnection s(URL url) throws IOException {
URLConnection openConnection = url.openConnection();
if (openConnection instanceof HttpURLConnection) {
HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
httpURLConnection.setDefaultUseCaches(false);
httpURLConnection.setConnectTimeout(60000);
httpURLConnection.setReadTimeout(61000);
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setDoInput(true);
return httpURLConnection;
}
throw new IOException("Failed to obtain HTTP connection");
}
}