MD5 校验值:61e58c10a11e4adec8760ee3854e996a
o.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package x2; import android.net.Uri; import android.text.TextUtils; import android.util.Log; import f0.AbstractC1761a; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.io.OutputStream; import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.NoRouteToHostException; import java.net.ProtocolException; import java.net.URL; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; import org.apache.http.HttpHeaders; import org.apache.http.HttpHost; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; import org.apache.http.client.methods.HttpPost; import org.apache.http.protocol.HTTP; public final class o extends d { public static final Pattern f19445r = Pattern.compile("^bytes (\\d+)-(\\d+)/(\\d+)$"); public static final AtomicReference f19446s = new AtomicReference(); public final boolean d; public final int e; public final int f19447f; public final String f19448g; public final g.k f19449h; public final g.k f19450i; public HttpURLConnection f19451j; public InputStream f19452k; public boolean f19453l; public int f19454m; public long f19455n; public long f19456o; public long f19457p; public long f19458q; public o(String str, int i5, int i6, boolean z6, g.k kVar) { super(true); if (!TextUtils.isEmpty(str)) { this.f19448g = str; this.f19450i = new g.k(); this.e = i5; this.f19447f = i6; this.d = z6; this.f19449h = kVar; return; } throw new IllegalArgumentException(); } public static URL i(URL url, String str) { if (str != null) { URL url2 = new URL(url, str); String protocol = url2.getProtocol(); if (!"https".equals(protocol) && !HttpHost.DEFAULT_SCHEME_NAME.equals(protocol)) { throw new ProtocolException(p4.r.n("Unsupported protocol redirect: ", protocol)); } return url2; } throw new ProtocolException("Null location redirect"); } public static void l(HttpURLConnection httpURLConnection, long j5) { int i5 = z2.q.f19694a; if (i5 != 19 && i5 != 20) { return; } try { InputStream inputStream = httpURLConnection.getInputStream(); if (j5 == -1) { if (inputStream.read() == -1) { return; } } else if (j5 <= 2048) { return; } String name = inputStream.getClass().getName(); if ("com.android.okhttp.internal.http.HttpTransport$ChunkedInputStream".equals(name) || "com.android.okhttp.internal.http.HttpTransport$FixedLengthInputStream".equals(name)) { Method declaredMethod = inputStream.getClass().getSuperclass().getDeclaredMethod("unexpectedEndOfInput", null); declaredMethod.setAccessible(true); declaredMethod.invoke(inputStream, null); } } catch (Exception unused) { } } @Override public final long a(k kVar) { long j5; long parseLong; String headerField; long j6; this.f19458q = 0L; this.f19457p = 0L; f(); try { HttpURLConnection k6 = k(kVar); this.f19451j = k6; try { this.f19454m = k6.getResponseCode(); this.f19451j.getResponseMessage(); int i5 = this.f19454m; if (i5 >= 200 && i5 <= 299) { this.f19451j.getContentType(); if (this.f19454m == 200) { j5 = kVar.f19412f; } j5 = 0; this.f19455n = j5; boolean equalsIgnoreCase = "gzip".equalsIgnoreCase(this.f19451j.getHeaderField("Content-Encoding")); long j7 = kVar.f19413g; if (equalsIgnoreCase || j7 != -1) { this.f19456o = j7; } else { HttpURLConnection httpURLConnection = this.f19451j; String headerField2 = httpURLConnection.getHeaderField("Content-Length"); if (!TextUtils.isEmpty(headerField2)) { try { parseLong = Long.parseLong(headerField2); } catch (NumberFormatException unused) { Log.e("DefaultHttpDataSource", "Unexpected Content-Length [" + headerField2 + "]"); } headerField = httpURLConnection.getHeaderField(HttpHeaders.CONTENT_RANGE); if (!TextUtils.isEmpty(headerField)) { Matcher matcher = f19445r.matcher(headerField); if (matcher.find()) { try { long parseLong2 = (Long.parseLong(matcher.group(2)) - Long.parseLong(matcher.group(1))) + 1; if (parseLong < 0) { parseLong = parseLong2; } else if (parseLong != parseLong2) { Log.w("DefaultHttpDataSource", "Inconsistent headers [" + headerField2 + "] [" + headerField + "]"); parseLong = Math.max(parseLong, parseLong2); } } catch (NumberFormatException unused2) { Log.e("DefaultHttpDataSource", "Unexpected Content-Range [" + headerField + "]"); } } } if (parseLong == -1) { j6 = parseLong - this.f19455n; } else { j6 = -1; } this.f19456o = j6; } parseLong = -1; headerField = httpURLConnection.getHeaderField(HttpHeaders.CONTENT_RANGE); if (!TextUtils.isEmpty(headerField)) { } if (parseLong == -1) { } this.f19456o = j6; } try { this.f19452k = this.f19451j.getInputStream(); if (equalsIgnoreCase) { this.f19452k = new GZIPInputStream(this.f19452k); } this.f19453l = true; g(kVar); return this.f19456o; } catch (IOException e) { h(); throw new IOException(e); } } this.f19451j.getHeaderFields(); h(); q qVar = new q(this.f19454m); if (this.f19454m == 416) { qVar.initCause(new i()); throw qVar; } throw qVar; } catch (IOException e7) { h(); throw new IOException("Unable to connect to " + kVar.f19409a.toString(), e7); } } catch (IOException e8) { throw new IOException("Unable to connect to " + kVar.f19409a.toString(), e8); } } @Override public final Map c() { HttpURLConnection httpURLConnection = this.f19451j; if (httpURLConnection == null) { return Collections.emptyMap(); } return httpURLConnection.getHeaderFields(); } @Override public final void close() { try { if (this.f19452k != null) { HttpURLConnection httpURLConnection = this.f19451j; long j5 = this.f19456o; if (j5 != -1) { j5 -= this.f19458q; } l(httpURLConnection, j5); try { this.f19452k.close(); } catch (IOException e) { throw new IOException(e); } } } finally { this.f19452k = null; h(); if (this.f19453l) { this.f19453l = false; e(); } } } @Override public final Uri getUri() { HttpURLConnection httpURLConnection = this.f19451j; if (httpURLConnection == null) { return null; } return Uri.parse(httpURLConnection.getURL().toString()); } public final void h() { HttpURLConnection httpURLConnection = this.f19451j; if (httpURLConnection != null) { try { httpURLConnection.disconnect(); } catch (Exception e) { Log.e("DefaultHttpDataSource", "Unexpected error while disconnecting", e); } this.f19451j = null; } } public final HttpURLConnection j(URL url, int i5, byte[] bArr, long j5, long j6, boolean z6, boolean z7, Map map) { String str; boolean z8; String str2; HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); httpURLConnection.setConnectTimeout(this.e); httpURLConnection.setReadTimeout(this.f19447f); HashMap hashMap = new HashMap(); g.k kVar = this.f19449h; if (kVar != null) { hashMap.putAll(kVar.j()); } hashMap.putAll(this.f19450i.j()); hashMap.putAll(map); for (Map.Entry entry : hashMap.entrySet()) { httpURLConnection.setRequestProperty((String) entry.getKey(), (String) entry.getValue()); } if (j5 != 0 || j6 != -1) { String str3 = "bytes=" + j5 + "-"; if (j6 != -1) { str3 = str3 + ((j5 + j6) - 1); } httpURLConnection.setRequestProperty(HttpHeaders.RANGE, str3); } httpURLConnection.setRequestProperty("User-Agent", this.f19448g); if (z6) { str = "gzip"; } else { str = HTTP.IDENTITY_CODING; } httpURLConnection.setRequestProperty(HttpHeaders.ACCEPT_ENCODING, str); httpURLConnection.setInstanceFollowRedirects(z7); if (bArr != null) { z8 = true; } else { z8 = false; } httpURLConnection.setDoOutput(z8); if (i5 != 1) { if (i5 != 2) { if (i5 == 3) { str2 = HttpHead.METHOD_NAME; } else { throw new AssertionError(i5); } } else { str2 = HttpPost.METHOD_NAME; } } else { str2 = HttpGet.METHOD_NAME; } httpURLConnection.setRequestMethod(str2); if (bArr != null) { httpURLConnection.setFixedLengthStreamingMode(bArr.length); httpURLConnection.connect(); OutputStream outputStream = httpURLConnection.getOutputStream(); outputStream.write(bArr); outputStream.close(); } else { httpURLConnection.connect(); } return httpURLConnection; } public final HttpURLConnection k(k kVar) { boolean z6; URL url = new URL(kVar.f19409a.toString()); int i5 = 0; if ((kVar.f19415i & 1) == 1) { z6 = true; } else { z6 = false; } boolean z7 = this.d; int i6 = kVar.f19410b; byte[] bArr = kVar.f19411c; long j5 = kVar.f19412f; long j6 = kVar.f19413g; if (!z7) { return j(url, i6, bArr, j5, j6, z6, true, kVar.d); } int i7 = i6; byte[] bArr2 = bArr; while (true) { int i8 = i5 + 1; if (i5 <= 20) { long j7 = j6; long j8 = j5; HttpURLConnection j9 = j(url, i7, bArr2, j5, j6, z6, false, kVar.d); int responseCode = j9.getResponseCode(); String headerField = j9.getHeaderField(HttpHeaders.LOCATION); if ((i7 != 1 && i7 != 3) || (responseCode != 300 && responseCode != 301 && responseCode != 302 && responseCode != 303 && responseCode != 307 && responseCode != 308)) { if (i7 != 2 || (responseCode != 300 && responseCode != 301 && responseCode != 302 && responseCode != 303)) { break; } j9.disconnect(); url = i(url, headerField); bArr2 = null; i7 = 1; } else { j9.disconnect(); url = i(url, headerField); } i5 = i8; j6 = j7; j5 = j8; } else { throw new NoRouteToHostException(AbstractC1761a.e(i8, "Too many redirects: ")); } } } public final void m() { if (this.f19457p == this.f19455n) { return; } AtomicReference atomicReference = f19446s; byte[] bArr = (byte[]) atomicReference.getAndSet(null); if (bArr == null) { bArr = new byte[4096]; } while (true) { long j5 = this.f19457p; long j6 = this.f19455n; if (j5 != j6) { int read = this.f19452k.read(bArr, 0, (int) Math.min(j6 - j5, bArr.length)); if (!Thread.currentThread().isInterrupted()) { if (read != -1) { this.f19457p += read; d(read); } else { throw new EOFException(); } } else { throw new InterruptedIOException(); } } else { atomicReference.set(bArr); return; } } } @Override public final int read(byte[] bArr, int i5, int i6) { try { m(); if (i6 == 0) { return 0; } long j5 = this.f19456o; if (j5 != -1) { long j6 = j5 - this.f19458q; if (j6 != 0) { i6 = (int) Math.min(i6, j6); } return -1; } int read = this.f19452k.read(bArr, i5, i6); if (read == -1) { if (this.f19456o == -1) { return -1; } throw new EOFException(); } this.f19458q += read; d(read); return read; } catch (IOException e) { throw new IOException(e); } } }