热汗舞蹈 v1.24.1.0版本的 MD5 值为:f1dc6ef07903515a73f51f41f372123e

以下内容为反编译后的 q.java 源代码,内容仅作参考


package com.alipay.android.phone.mrpc.core;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.text.TextUtils;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import com.huawei.hms.framework.common.ContainerUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.cookie.Cookie;
import org.apache.http.entity.AbstractHttpEntity;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
public final class q implements Callable<u> {
    public static final HttpRequestRetryHandler f5589e = new ad();
    public l f5590a;
    public Context f5591b;
    public o f5592c;
    public String f5593d;
    public HttpUriRequest f5594f;
    public CookieManager f5597i;
    public AbstractHttpEntity f5598j;
    public HttpHost f5599k;
    public URL f5600l;
    public String f5605q;
    public HttpContext f5595g = new BasicHttpContext();
    public CookieStore f5596h = new BasicCookieStore();
    public int f5601m = 0;
    public boolean f5602n = false;
    public boolean f5603o = false;
    public String f5604p = null;

    public q(l lVar, o oVar) {
        this.f5590a = lVar;
        this.f5591b = lVar.f5567a;
        this.f5592c = oVar;
    }

    public static long a(String[] strArr) {
        for (int i10 = 0; i10 < strArr.length; i10++) {
            if ("max-age".equalsIgnoreCase(strArr[i10])) {
                int i11 = i10 + 1;
                if (strArr[i11] != null) {
                    try {
                        return Long.parseLong(strArr[i11]);
                    } catch (Exception unused) {
                        continue;
                    }
                } else {
                    continue;
                }
            }
        }
        return 0L;
    }

    public static HttpUrlHeader a(HttpResponse httpResponse) {
        Header[] allHeaders;
        HttpUrlHeader httpUrlHeader = new HttpUrlHeader();
        for (Header header : httpResponse.getAllHeaders()) {
            httpUrlHeader.setHead(header.getName(), header.getValue());
        }
        return httpUrlHeader;
    }

    private u a(HttpResponse httpResponse, int i10, String str) {
        String str2;
        Thread.currentThread().getId();
        HttpEntity entity = httpResponse.getEntity();
        ByteArrayOutputStream byteArrayOutputStream = null;
        String str3 = null;
        if (entity == null || httpResponse.getStatusLine().getStatusCode() != 200) {
            if (entity == null) {
                httpResponse.getStatusLine().getStatusCode();
                return null;
            }
            return null;
        }
        Thread.currentThread().getId();
        try {
            ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
            try {
                long currentTimeMillis = System.currentTimeMillis();
                a(entity, byteArrayOutputStream2);
                byte[] byteArray = byteArrayOutputStream2.toByteArray();
                this.f5603o = false;
                this.f5590a.c(System.currentTimeMillis() - currentTimeMillis);
                this.f5590a.a(byteArray.length);
                p pVar = new p(a(httpResponse), i10, str, byteArray);
                long b10 = b(httpResponse);
                Header contentType = httpResponse.getEntity().getContentType();
                if (contentType != null) {
                    HashMap<String, String> a10 = a(contentType.getValue());
                    str3 = a10.get("charset");
                    str2 = a10.get("Content-Type");
                } else {
                    str2 = null;
                }
                pVar.b(str2);
                pVar.a(str3);
                pVar.a(System.currentTimeMillis());
                pVar.b(b10);
                try {
                    byteArrayOutputStream2.close();
                    return pVar;
                } catch (IOException e10) {
                    throw new RuntimeException("ArrayOutputStream close error!", e10.getCause());
                }
            } catch (Throwable th) {
                th = th;
                byteArrayOutputStream = byteArrayOutputStream2;
                if (byteArrayOutputStream != null) {
                    try {
                        byteArrayOutputStream.close();
                    } catch (IOException e11) {
                        throw new RuntimeException("ArrayOutputStream close error!", e11.getCause());
                    }
                }
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static HashMap<String, String> a(String str) {
        String[] split;
        HashMap<String, String> hashMap = new HashMap<>();
        for (String str2 : str.split(";")) {
            String[] split2 = str2.indexOf(61) == -1 ? new String[]{"Content-Type", str2} : str2.split(ContainerUtils.KEY_VALUE_DELIMITER);
            hashMap.put(split2[0], split2[1]);
        }
        return hashMap;
    }

    private void a(HttpEntity httpEntity, OutputStream outputStream) {
        InputStream a10 = b.a(httpEntity);
        httpEntity.getContentLength();
        try {
            try {
                byte[] bArr = new byte[2048];
                while (true) {
                    int read = a10.read(bArr);
                    if (read == -1 || this.f5592c.h()) {
                        break;
                    }
                    outputStream.write(bArr, 0, read);
                    this.f5592c.f();
                }
                outputStream.flush();
            } catch (Exception e10) {
                e10.getCause();
                throw new IOException("HttpWorker Request Error!" + e10.getLocalizedMessage());
            }
        } finally {
            r.a(a10);
        }
    }

    public static long b(HttpResponse httpResponse) {
        Header firstHeader = httpResponse.getFirstHeader("Cache-Control");
        if (firstHeader != null) {
            String[] split = firstHeader.getValue().split(ContainerUtils.KEY_VALUE_DELIMITER);
            if (split.length >= 2) {
                try {
                    return a(split);
                } catch (NumberFormatException unused) {
                }
            }
        }
        Header firstHeader2 = httpResponse.getFirstHeader("Expires");
        if (firstHeader2 != null) {
            return b.b(firstHeader2.getValue()) - System.currentTimeMillis();
        }
        return 0L;
    }

    private URI b() {
        String a10 = this.f5592c.a();
        String str = this.f5593d;
        if (str != null) {
            a10 = str;
        }
        if (a10 != null) {
            return new URI(a10);
        }
        throw new RuntimeException("url should not be null");
    }

    private HttpUriRequest c() {
        HttpUriRequest httpUriRequest = this.f5594f;
        if (httpUriRequest != null) {
            return httpUriRequest;
        }
        if (this.f5598j == null) {
            byte[] b10 = this.f5592c.b();
            String b11 = this.f5592c.b("gzip");
            if (b10 != null) {
                if (TextUtils.equals(b11, "true")) {
                    this.f5598j = b.a(b10);
                } else {
                    this.f5598j = new ByteArrayEntity(b10);
                }
                this.f5598j.setContentType(this.f5592c.c());
            }
        }
        AbstractHttpEntity abstractHttpEntity = this.f5598j;
        if (abstractHttpEntity != null) {
            HttpPost httpPost = new HttpPost(b());
            httpPost.setEntity(abstractHttpEntity);
            this.f5594f = httpPost;
        } else {
            this.f5594f = new HttpGet(b());
        }
        return this.f5594f;
    }

    @Override
    public u call() {
        boolean z10;
        HttpHost httpHost;
        HttpHost httpHost2;
        List<Cookie> cookies;
        int statusCode;
        u a10;
        while (true) {
            try {
                NetworkInfo[] allNetworkInfo = ((ConnectivityManager) this.f5591b.getSystemService("connectivity")).getAllNetworkInfo();
                boolean z11 = true;
                if (allNetworkInfo != null) {
                    for (NetworkInfo networkInfo : allNetworkInfo) {
                        if (networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnectedOrConnecting()) {
                            z10 = true;
                            break;
                        }
                    }
                }
                z10 = false;
                if (z10) {
                    ArrayList<Header> d10 = this.f5592c.d();
                    if (d10 != null && !d10.isEmpty()) {
                        Iterator<Header> it = d10.iterator();
                        while (it.hasNext()) {
                            c().addHeader(it.next());
                        }
                    }
                    b.a((HttpRequest) c());
                    b.b((HttpRequest) c());
                    c().addHeader("cookie", i().getCookie(this.f5592c.a()));
                    this.f5595g.setAttribute("http.cookie-store", this.f5596h);
                    this.f5590a.a().a(f5589e);
                    long currentTimeMillis = System.currentTimeMillis();
                    f();
                    this.f5594f.getURI().toString();
                    HttpParams params = this.f5590a.a().getParams();
                    NetworkInfo activeNetworkInfo = ((ConnectivityManager) this.f5591b.getSystemService("connectivity")).getActiveNetworkInfo();
                    HttpHost httpHost3 = null;
                    if (activeNetworkInfo != null && activeNetworkInfo.isAvailable()) {
                        String defaultHost = Proxy.getDefaultHost();
                        int defaultPort = Proxy.getDefaultPort();
                        if (defaultHost != null) {
                            httpHost = new HttpHost(defaultHost, defaultPort);
                            if (httpHost != null || !TextUtils.equals(httpHost.getHostName(), "127.0.0.1") || httpHost.getPort() != 8087) {
                                httpHost3 = httpHost;
                            }
                            params.setParameter("http.route.default-proxy", httpHost3);
                            httpHost2 = this.f5599k;
                            if (httpHost2 != null) {
                                URL h10 = h();
                                HttpHost httpHost4 = new HttpHost(h10.getHost(), g(), h10.getProtocol());
                                this.f5599k = httpHost4;
                                httpHost2 = httpHost4;
                            }
                            if (g() == 80) {
                                httpHost2 = new HttpHost(h().getHost());
                            }
                            HttpResponse execute = this.f5590a.a().execute(httpHost2, (HttpRequest) this.f5594f, this.f5595g);
                            this.f5590a.b(System.currentTimeMillis() - currentTimeMillis);
                            cookies = this.f5596h.getCookies();
                            if (this.f5592c.e()) {
                                i().removeAllCookie();
                            }
                            if (!cookies.isEmpty()) {
                                for (Cookie cookie : cookies) {
                                    if (cookie.getDomain() != null) {
                                        StringBuilder sb2 = new StringBuilder();
                                        sb2.append(cookie.getName());
                                        sb2.append(ContainerUtils.KEY_VALUE_DELIMITER);
                                        sb2.append(cookie.getValue());
                                        sb2.append("; domain=");
                                        sb2.append(cookie.getDomain());
                                        sb2.append(cookie.isSecure() ? "; Secure" : "");
                                        i().setCookie(this.f5592c.a(), sb2.toString());
                                        CookieSyncManager.getInstance().sync();
                                    }
                                }
                            }
                            statusCode = execute.getStatusLine().getStatusCode();
                            String reasonPhrase = execute.getStatusLine().getReasonPhrase();
                            if (statusCode != 200) {
                                if (statusCode != 304) {
                                    z11 = false;
                                }
                                if (!z11) {
                                    throw new HttpException(Integer.valueOf(execute.getStatusLine().getStatusCode()), execute.getStatusLine().getReasonPhrase());
                                }
                            }
                            a10 = a(execute, statusCode, reasonPhrase);
                            if (((a10 != null || a10.b() == null) ? -1L : a10.b().length) == -1 && (a10 instanceof p)) {
                                try {
                                    Long.parseLong(((p) a10).a().getHead("Content-Length"));
                                } catch (Exception unused) {
                                }
                            }
                            if (this.f5592c.a() != null && !TextUtils.isEmpty(f())) {
                                f();
                            }
                            return a10;
                        }
                    }
                    httpHost = null;
                    if (httpHost != null) {
                    }
                    httpHost3 = httpHost;
                    params.setParameter("http.route.default-proxy", httpHost3);
                    httpHost2 = this.f5599k;
                    if (httpHost2 != null) {
                    }
                    if (g() == 80) {
                    }
                    HttpResponse execute2 = this.f5590a.a().execute(httpHost2, (HttpRequest) this.f5594f, this.f5595g);
                    this.f5590a.b(System.currentTimeMillis() - currentTimeMillis);
                    cookies = this.f5596h.getCookies();
                    if (this.f5592c.e()) {
                    }
                    if (!cookies.isEmpty()) {
                    }
                    statusCode = execute2.getStatusLine().getStatusCode();
                    String reasonPhrase2 = execute2.getStatusLine().getReasonPhrase();
                    if (statusCode != 200) {
                    }
                    a10 = a(execute2, statusCode, reasonPhrase2);
                    if (((a10 != null || a10.b() == null) ? -1L : a10.b().length) == -1) {
                        Long.parseLong(((p) a10).a().getHead("Content-Length"));
                    }
                    if (this.f5592c.a() != null) {
                        f();
                    }
                    return a10;
                }
                throw new HttpException(1, "The network is not available");
            } catch (HttpException e10) {
                e();
                if (this.f5592c.f() != null) {
                    e10.getCode();
                    e10.getMsg();
                }
                e10.toString();
                throw e10;
            } catch (NullPointerException e11) {
                e();
                int i10 = this.f5601m;
                if (i10 > 0) {
                    e11.toString();
                    throw new HttpException(0, String.valueOf(e11));
                }
                this.f5601m = i10 + 1;
            } catch (SocketTimeoutException e12) {
                e();
                if (this.f5592c.f() != null) {
                    e12.toString();
                }
                e12.toString();
                throw new HttpException(4, String.valueOf(e12));
            } catch (UnknownHostException e13) {
                e();
                if (this.f5592c.f() != null) {
                    e13.toString();
                }
                e13.toString();
                throw new HttpException(9, String.valueOf(e13));
            } catch (SSLHandshakeException e14) {
                e();
                if (this.f5592c.f() != null) {
                    e14.toString();
                }
                e14.toString();
                throw new HttpException(2, String.valueOf(e14));
            } catch (ConnectTimeoutException e15) {
                e();
                if (this.f5592c.f() != null) {
                    e15.toString();
                }
                e15.toString();
                throw new HttpException(3, String.valueOf(e15));
            } catch (IOException e16) {
                e();
                if (this.f5592c.f() != null) {
                    e16.toString();
                }
                e16.toString();
                throw new HttpException(6, String.valueOf(e16));
            } catch (HttpHostConnectException e17) {
                e();
                if (this.f5592c.f() != null) {
                    e17.toString();
                }
                throw new HttpException(8, String.valueOf(e17));
            } catch (SSLPeerUnverifiedException e18) {
                e();
                if (this.f5592c.f() != null) {
                    e18.toString();
                }
                e18.toString();
                throw new HttpException(2, String.valueOf(e18));
            } catch (SSLException e19) {
                e();
                if (this.f5592c.f() != null) {
                    e19.toString();
                }
                e19.toString();
                throw new HttpException(6, String.valueOf(e19));
            } catch (NoHttpResponseException e20) {
                e();
                if (this.f5592c.f() != null) {
                    e20.toString();
                }
                e20.toString();
                throw new HttpException(5, String.valueOf(e20));
            } catch (Exception e21) {
                e();
                if (this.f5592c.f() != null) {
                    e21.toString();
                }
                throw new HttpException(0, String.valueOf(e21));
            } catch (ConnectionPoolTimeoutException e22) {
                e();
                if (this.f5592c.f() != null) {
                    e22.toString();
                }
                e22.toString();
                throw new HttpException(3, String.valueOf(e22));
            } catch (URISyntaxException e23) {
                throw new RuntimeException("Url parser error!", e23.getCause());
            }
        }
    }

    private void e() {
        HttpUriRequest httpUriRequest = this.f5594f;
        if (httpUriRequest != null) {
            httpUriRequest.abort();
        }
    }

    private String f() {
        if (TextUtils.isEmpty(this.f5605q)) {
            String b10 = this.f5592c.b("operationType");
            this.f5605q = b10;
            return b10;
        }
        return this.f5605q;
    }

    private int g() {
        URL h10 = h();
        return h10.getPort() == -1 ? h10.getDefaultPort() : h10.getPort();
    }

    private URL h() {
        URL url = this.f5600l;
        if (url != null) {
            return url;
        }
        URL url2 = new URL(this.f5592c.a());
        this.f5600l = url2;
        return url2;
    }

    private CookieManager i() {
        CookieManager cookieManager = this.f5597i;
        if (cookieManager != null) {
            return cookieManager;
        }
        CookieManager cookieManager2 = CookieManager.getInstance();
        this.f5597i = cookieManager2;
        return cookieManager2;
    }

    public final o a() {
        return this.f5592c;
    }
}