51黑料 v2.0版本的 MD5 值为:cc00ad70c70d95f274d15d4654c16262
以下内容为反编译后的 i.java 源代码,内容仅作参考
package g.e.a;
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 class i implements p {
public final g.e.a.t.c a;
public final g.e.a.s.b b;
public q c;
public HttpURLConnection f2588d;
public InputStream f2589e;
public i(String str, g.e.a.t.c cVar, g.e.a.s.b bVar) {
Objects.requireNonNull(cVar);
this.a = cVar;
Objects.requireNonNull(bVar);
this.b = bVar;
q qVar = cVar.get(str);
if (qVar == null) {
MimeTypeMap singleton = MimeTypeMap.getSingleton();
String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
qVar = new q(str, -2147483648L, TextUtils.isEmpty(fileExtensionFromUrl) ? null : singleton.getMimeTypeFromExtension(fileExtensionFromUrl));
}
this.c = qVar;
}
@Override
public void a(long j2) {
try {
HttpURLConnection c = c(j2, -1);
this.f2588d = c;
String contentType = c.getContentType();
this.f2589e = new BufferedInputStream(this.f2588d.getInputStream(), 8192);
HttpURLConnection httpURLConnection = this.f2588d;
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 + j2 : this.c.b;
}
String str = this.c.a;
q qVar = new q(str, parseLong, contentType);
this.c = qVar;
this.a.b(str, qVar);
} catch (IOException e2) {
StringBuilder O = g.b.a.a.a.O("Error opening connection for ");
O.append(this.c.a);
O.append(" with offset ");
O.append(j2);
throw new n(O.toString(), e2);
}
}
public final void b() {
HttpURLConnection httpURLConnection;
HttpURLConnection httpURLConnection2;
InputStream inputStream = null;
try {
httpURLConnection2 = c(0L, 10000);
try {
try {
String headerField = httpURLConnection2.getHeaderField("Content-Length");
long parseLong = headerField == null ? -1L : Long.parseLong(headerField);
String contentType = httpURLConnection2.getContentType();
inputStream = httpURLConnection2.getInputStream();
String str = this.c.a;
q qVar = new q(str, parseLong, contentType);
this.c = qVar;
this.a.b(str, qVar);
o.a(inputStream);
} catch (IOException e2) {
e = e2;
f.a("Error fetching info from " + this.c.a, e);
o.a(inputStream);
if (httpURLConnection2 == null) {
return;
}
httpURLConnection2.disconnect();
}
} catch (Throwable th) {
InputStream inputStream2 = inputStream;
HttpURLConnection httpURLConnection3 = httpURLConnection2;
inputStream = inputStream2;
th = th;
httpURLConnection = httpURLConnection3;
o.a(inputStream);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
throw th;
}
} catch (IOException e3) {
e = e3;
httpURLConnection2 = null;
} catch (Throwable th2) {
th = th2;
httpURLConnection = null;
o.a(inputStream);
if (httpURLConnection != null) {
}
throw th;
}
httpURLConnection2.disconnect();
}
public final HttpURLConnection c(long j2, int i2) {
HttpURLConnection httpURLConnection;
boolean z;
String str = this.c.a;
int i3 = 0;
do {
httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
Map<String, String> a = this.b.a(str);
if (a != null) {
StringBuilder O = g.b.a.a.a.O("****** injectCustomHeaders ****** :");
O.append(a.size());
TextUtils.isEmpty(O.toString());
for (Map.Entry<String, String> entry : a.entrySet()) {
httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
if (j2 > 0) {
httpURLConnection.setRequestProperty("Range", g.b.a.a.a.w("bytes=", j2, "-"));
}
if (i2 > 0) {
httpURLConnection.setConnectTimeout(i2);
httpURLConnection.setReadTimeout(i2);
}
int responseCode = httpURLConnection.getResponseCode();
z = responseCode == 301 || responseCode == 302 || responseCode == 303;
if (z) {
str = httpURLConnection.getHeaderField("Location");
i3++;
httpURLConnection.disconnect();
}
if (i3 > 5) {
throw new n(g.b.a.a.a.s("Too many redirects: ", i3));
}
} while (z);
return httpURLConnection;
}
@Override
public void close() {
HttpURLConnection httpURLConnection = this.f2588d;
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (ArrayIndexOutOfBoundsException e2) {
f.a("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 :(", e2);
} catch (IllegalArgumentException e3) {
e = e3;
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 e4) {
e = e4;
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 synchronized long length() {
if (this.c.b == -2147483648L) {
b();
}
return this.c.b;
}
@Override
public int read(byte[] bArr) {
InputStream inputStream = this.f2589e;
if (inputStream != null) {
try {
return inputStream.read(bArr, 0, bArr.length);
} catch (InterruptedIOException e2) {
throw new k(g.b.a.a.a.J(g.b.a.a.a.O("Reading source "), this.c.a, " is interrupted"), e2);
} catch (IOException e3) {
StringBuilder O = g.b.a.a.a.O("Error reading data from ");
O.append(this.c.a);
throw new n(O.toString(), e3);
}
}
throw new n(g.b.a.a.a.J(g.b.a.a.a.O("Error reading data from "), this.c.a, ": connection is absent!"));
}
public String toString() {
StringBuilder O = g.b.a.a.a.O("HttpUrlSource{sourceInfo='");
O.append(this.c);
O.append("}");
return O.toString();
}
public i(i iVar) {
this.c = iVar.c;
this.a = iVar.a;
this.b = iVar.b;
}
}