涩里番 v4.2版本的 MD5 值为:b7af51031b798a68c7a3a9ba5a0dff66
以下内容为反编译后的 h.java 源代码,内容仅作参考
package m4;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import java.util.Objects;
public final class h implements n {
public final p4.b f11360a;
public final o4.a f11361b;
public o f11362c;
public HttpURLConnection f11363d;
public BufferedInputStream f11364e;
public h(String str, p4.b bVar, o4.a aVar) {
Objects.requireNonNull(bVar);
this.f11360a = bVar;
Objects.requireNonNull(aVar);
this.f11361b = aVar;
o u02 = bVar.u0(str);
if (u02 == null) {
MimeTypeMap singleton = MimeTypeMap.getSingleton();
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
u02 = new o(str, -2147483648L, TextUtils.isEmpty(fileExtensionFromUrl) ? null : singleton.getMimeTypeFromExtension(fileExtensionFromUrl));
}
this.f11362c = u02;
}
@Override
public final void a(long j10) {
try {
HttpURLConnection c10 = c(j10, -1);
this.f11363d = c10;
String contentType = c10.getContentType();
this.f11364e = new BufferedInputStream(this.f11363d.getInputStream(), 8192);
HttpURLConnection httpURLConnection = this.f11363d;
int responseCode = httpURLConnection.getResponseCode();
String headerField = httpURLConnection.getHeaderField("Content-Length");
long parseLong = headerField == null ? -1L : Long.parseLong(headerField);
if (responseCode != 200) {
parseLong = responseCode == 206 ? parseLong + j10 : this.f11362c.f11383b;
}
String str = this.f11362c.f11382a;
o oVar = new o(str, parseLong, contentType);
this.f11362c = oVar;
this.f11360a.y(str, oVar);
} catch (IOException e10) {
StringBuilder r = af.j.r("Error opening connection for ");
r.append(this.f11362c.f11382a);
r.append(" with offset ");
r.append(j10);
throw new m(r.toString(), e10);
}
}
public final void b() {
HttpURLConnection httpURLConnection;
InputStream inputStream = null;
try {
httpURLConnection = c(0L, 10000);
try {
try {
String headerField = httpURLConnection.getHeaderField("Content-Length");
long parseLong = headerField == null ? -1L : Long.parseLong(headerField);
String contentType = httpURLConnection.getContentType();
inputStream = httpURLConnection.getInputStream();
String str = this.f11362c.f11382a;
o oVar = new o(str, parseLong, contentType);
this.f11362c = oVar;
this.f11360a.y(str, oVar);
z2.a.B(inputStream);
} catch (IOException e10) {
e = e10;
a3.c.G("Error fetching info from " + this.f11362c.f11382a, e);
z2.a.B(inputStream);
if (httpURLConnection == null) {
return;
}
httpURLConnection.disconnect();
}
} catch (Throwable th) {
th = th;
z2.a.B(inputStream);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
throw th;
}
} catch (IOException e11) {
e = e11;
httpURLConnection = null;
} catch (Throwable th2) {
th = th2;
httpURLConnection = null;
z2.a.B(inputStream);
if (httpURLConnection != null) {
}
throw th;
}
httpURLConnection.disconnect();
}
public final HttpURLConnection c(long j10, int i2) {
HttpURLConnection httpURLConnection;
boolean z10;
String str = this.f11362c.f11382a;
int i10 = 0;
do {
httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
Map a10 = this.f11361b.a();
if (a10 != null) {
StringBuilder r = af.j.r("****** injectCustomHeaders ****** :");
r.append(a10.size());
TextUtils.isEmpty(r.toString());
for (Map.Entry entry : a10.entrySet()) {
httpURLConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue());
}
}
if (j10 > 0) {
httpURLConnection.setRequestProperty("Range", "bytes=" + j10 + "-");
}
if (i2 > 0) {
httpURLConnection.setConnectTimeout(i2);
httpURLConnection.setReadTimeout(i2);
}
int responseCode = httpURLConnection.getResponseCode();
z10 = responseCode == 301 || responseCode == 302 || responseCode == 303;
if (z10) {
str = httpURLConnection.getHeaderField("Location");
i10++;
httpURLConnection.disconnect();
}
if (i10 > 5) {
throw new m(af.j.i("Too many redirects: ", i10));
}
} while (z10);
return httpURLConnection;
}
@Override
public final void close() {
HttpURLConnection httpURLConnection = this.f11363d;
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (ArrayIndexOutOfBoundsException e10) {
a3.c.G("Error closing connection correctly. Should happen only on Android L. If anybody know how to fix it, please visit https://github.com/danikula/AndroidVideoCache/issues/88. Until good solution is not know, just ignore this issue :(", e10);
} catch (IllegalArgumentException e11) {
e = e11;
throw new RuntimeException("Wait... but why? WTF!? Really shouldn't happen any more after fixing https://github.com/danikula/AndroidVideoCache/issues/43. If you read it on your device log, please, notify me danikula@gmail.com or create issue here https://github.com/danikula/AndroidVideoCache/issues.", e);
} catch (NullPointerException e12) {
e = e12;
throw new RuntimeException("Wait... but why? WTF!? Really shouldn't happen any more after fixing https://github.com/danikula/AndroidVideoCache/issues/43. If you read it on your device log, please, notify me danikula@gmail.com or create issue here https://github.com/danikula/AndroidVideoCache/issues.", e);
}
}
}
@Override
public final synchronized long length() {
if (this.f11362c.f11383b == -2147483648L) {
b();
}
return this.f11362c.f11383b;
}
@Override
public final int read(byte[] bArr) {
BufferedInputStream bufferedInputStream = this.f11364e;
if (bufferedInputStream != null) {
try {
return bufferedInputStream.read(bArr, 0, bArr.length);
} catch (InterruptedIOException e10) {
throw new j(l.o.d(af.j.r("Reading source "), this.f11362c.f11382a, " is interrupted"), e10);
} catch (IOException e11) {
StringBuilder r = af.j.r("Error reading data from ");
r.append(this.f11362c.f11382a);
throw new m(r.toString(), e11);
}
}
throw new m(l.o.d(af.j.r("Error reading data from "), this.f11362c.f11382a, ": connection is absent!"));
}
public final String toString() {
StringBuilder r = af.j.r("HttpUrlSource{sourceInfo='");
r.append(this.f11362c);
r.append("}");
return r.toString();
}
public h(h hVar) {
this.f11362c = hVar.f11362c;
this.f11360a = hVar.f11360a;
this.f11361b = hVar.f11361b;
}
}