米游社.apk(点击下载) / e.java


package wz;

import com.google.common.net.HttpHeaders;
import com.huawei.hms.framework.common.ContainerUtils;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.tencent.qcloud.core.util.IOUtils;
import io.rong.imlib.filetransfer.download.BaseRequest;
import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.CookieManager;
import java.net.CookieStore;
import java.net.HttpURLConnection;
import java.net.IDN;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import javax.annotation.Nullable;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
import t4.h;
import vz.a;
import xx.h0;
import xz.f;
import zz.g;
import zz.j;

/* compiled from: HttpConnection */
public class e implements vz.a {

    /* renamed from: c  reason: collision with root package name */
    public static final String f155925c = "Content-Encoding";

    /* renamed from: d  reason: collision with root package name */
    public static final String f155926d = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36";

    /* renamed from: e  reason: collision with root package name */
    public static final String f155927e = "User-Agent";

    /* renamed from: f  reason: collision with root package name */
    public static final String f155928f = "Content-Type";

    /* renamed from: g  reason: collision with root package name */
    public static final String f155929g = "multipart/form-data";

    /* renamed from: h  reason: collision with root package name */
    public static final String f155930h = "application/x-www-form-urlencoded";

    /* renamed from: i  reason: collision with root package name */
    public static final int f155931i = 307;

    /* renamed from: j  reason: collision with root package name */
    public static final String f155932j = "application/octet-stream";

    /* renamed from: k  reason: collision with root package name */
    public static final Charset f155933k = Charset.forName("UTF-8");

    /* renamed from: l  reason: collision with root package name */
    public static final Charset f155934l = Charset.forName("ISO-8859-1");

    /* renamed from: a  reason: collision with root package name */
    public d f155935a;
    @Nullable

    /* renamed from: b  reason: collision with root package name */
    public a.e f155936b;

    /* compiled from: HttpConnection */
    public static class c implements a.b {

        /* renamed from: a  reason: collision with root package name */
        public String f155942a;

        /* renamed from: b  reason: collision with root package name */
        public String f155943b;
        @Nullable

        /* renamed from: c  reason: collision with root package name */
        public InputStream f155944c;
        @Nullable

        /* renamed from: d  reason: collision with root package name */
        public String f155945d;

        public c(String str, String str2) {
            f.l(str, "key");
            f.o(str2, "value");
            this.f155942a = str;
            this.f155943b = str2;
        }

        public static c f(String str, String str2) {
            return new c(str, str2);
        }

        public static c g(String str, String str2, InputStream inputStream) {
            return new c(str, str2).d(inputStream);
        }

        @Override // vz.a.b
        public a.b a(String str) {
            f.j(str);
            this.f155945d = str;
            return this;
        }

        @Override // vz.a.b
        public String contentType() {
            return this.f155945d;
        }

        @Override // vz.a.b
        public boolean e() {
            return this.f155944c != null;
        }

        /* renamed from: h */
        public c d(InputStream inputStream) {
            f.o(this.f155943b, "inputStream");
            this.f155944c = inputStream;
            return this;
        }

        /* renamed from: i */
        public c b(String str) {
            f.l(str, "key");
            this.f155942a = str;
            return this;
        }

        @Override // vz.a.b
        public InputStream inputStream() {
            return this.f155944c;
        }

        /* renamed from: j */
        public c c(String str) {
            f.o(str, "value");
            this.f155943b = str;
            return this;
        }

        @Override // vz.a.b
        public String key() {
            return this.f155942a;
        }

        public String toString() {
            return this.f155942a + ContainerUtils.KEY_VALUE_DELIMITER + this.f155943b;
        }

        @Override // vz.a.b
        public String value() {
            return this.f155943b;
        }
    }

    public static vz.a N(String str) {
        e eVar = new e();
        eVar.x(str);
        return eVar;
    }

    public static vz.a O(URL url) {
        e eVar = new e();
        eVar.i(url);
        return eVar;
    }

    public static String P(String str) {
        return str.replace("\"", "%22");
    }

    public static String Q(String str) {
        try {
            return R(new URL(str)).toExternalForm();
        } catch (Exception unused) {
            return str;
        }
    }

    public static URL R(URL url) {
        URL T = T(url);
        try {
            return new URL(new URI(T.toExternalForm().replace(gc.c.f66526t, "%20")).toASCIIString());
        } catch (MalformedURLException | URISyntaxException unused) {
            return T;
        }
    }

    public static boolean S(a.d dVar) {
        for (a.b bVar : dVar.e()) {
            if (bVar.e()) {
                return true;
            }
        }
        return false;
    }

    public static URL T(URL url) {
        if (f.f(url.getHost())) {
            return url;
        }
        try {
            return new URL(url.getProtocol(), IDN.toASCII(url.getHost()), url.getPort(), url.getFile());
        } catch (MalformedURLException e10) {
            throw new IllegalArgumentException(e10);
        }
    }

    @Override // vz.a
    public CookieStore A() {
        return this.f155935a.f155958r.getCookieStore();
    }

    @Override // vz.a
    public vz.a B(String str) {
        f.o(str, "referrer");
        this.f155935a.j(HttpHeaders.REFERER, str);
        return this;
    }

    @Override // vz.a
    public vz.a C(Map<String, String> map) {
        f.o(map, "cookies");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            this.f155935a.c(entry.getKey(), entry.getValue());
        }
        return this;
    }

    @Override // vz.a
    public vz.a D(String str, String str2, InputStream inputStream) {
        this.f155935a.r(c.g(str, str2, inputStream));
        return this;
    }

    @Override // vz.a
    public vz.a E(String... strArr) {
        f.o(strArr, "keyvals");
        f.g(strArr.length % 2 == 0, "Must supply an even number of key value pairs");
        for (int i10 = 0; i10 < strArr.length; i10 += 2) {
            String str = strArr[i10];
            String str2 = strArr[i10 + 1];
            f.k(str, "Data key must not be empty");
            f.n(str2, "Data value must not be null");
            this.f155935a.r(c.f(str, str2));
        }
        return this;
    }

    @Override // vz.a
    public a.b F(String str) {
        f.l(str, "key");
        for (a.b bVar : request().e()) {
            if (bVar.key().equals(str)) {
                return bVar;
            }
        }
        return null;
    }

    @Override // vz.a
    public vz.a G(a.e eVar) {
        this.f155936b = eVar;
        return this;
    }

    @Override // vz.a
    public vz.a H(Map<String, String> map) {
        f.o(map, "data");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            this.f155935a.r(c.f(entry.getKey(), entry.getValue()));
        }
        return this;
    }

    @Override // vz.a
    public vz.a a(boolean z10) {
        this.f155935a.a(z10);
        return this;
    }

    @Override // vz.a
    public vz.a b(String str) {
        this.f155935a.b(str);
        return this;
    }

    @Override // vz.a
    public vz.a c(String str, String str2) {
        this.f155935a.c(str, str2);
        return this;
    }

    @Override // vz.a
    public vz.a d(int i10) {
        this.f155935a.d(i10);
        return this;
    }

    @Override // vz.a
    public vz.a e(Collection<a.b> collection) {
        f.o(collection, "data");
        for (a.b bVar : collection) {
            this.f155935a.r(bVar);
        }
        return this;
    }

    @Override // vz.a
    public a.e execute() throws IOException {
        C1260e b02 = C1260e.b0(this.f155935a);
        this.f155936b = b02;
        return b02;
    }

    @Override // vz.a
    public vz.a f(SSLSocketFactory sSLSocketFactory) {
        this.f155935a.f(sSLSocketFactory);
        return this;
    }

    @Override // vz.a
    public vz.a g(String str) {
        this.f155935a.g(str);
        return this;
    }

    @Override // vz.a
    public yz.f get() throws IOException {
        this.f155935a.p(a.c.GET);
        execute();
        f.m(this.f155936b);
        return this.f155936b.B();
    }

    @Override // vz.a
    public vz.a h(@Nullable Proxy proxy) {
        this.f155935a.h(proxy);
        return this;
    }

    @Override // vz.a
    public vz.a i(URL url) {
        this.f155935a.i(url);
        return this;
    }

    @Override // vz.a
    public vz.a j(String str, String str2) {
        this.f155935a.j(str, str2);
        return this;
    }

    @Override // vz.a
    public vz.a k(String str, int i10) {
        this.f155935a.k(str, i10);
        return this;
    }

    @Override // vz.a
    public vz.a l(g gVar) {
        this.f155935a.l(gVar);
        return this;
    }

    @Override // vz.a
    public vz.a m(int i10) {
        this.f155935a.m(i10);
        return this;
    }

    @Override // vz.a
    public vz.a n(boolean z10) {
        this.f155935a.n(z10);
        return this;
    }

    @Override // vz.a
    public vz.a o(boolean z10) {
        this.f155935a.o(z10);
        return this;
    }

    @Override // vz.a
    public vz.a p(a.c cVar) {
        this.f155935a.p(cVar);
        return this;
    }

    @Override // vz.a
    public vz.a q(Map<String, String> map) {
        f.o(map, "headers");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            this.f155935a.j(entry.getKey(), entry.getValue());
        }
        return this;
    }

    @Override // vz.a
    public vz.a r(String str, String str2, InputStream inputStream, String str3) {
        this.f155935a.r(c.g(str, str2, inputStream).a(str3));
        return this;
    }

    @Override // vz.a
    public a.d request() {
        return this.f155935a;
    }

    @Override // vz.a
    public vz.a s() {
        return new e(this.f155935a);
    }

    @Override // vz.a
    public vz.a t(String str, String str2) {
        this.f155935a.r(c.f(str, str2));
        return this;
    }

    @Override // vz.a
    public yz.f u() throws IOException {
        this.f155935a.p(a.c.POST);
        execute();
        f.m(this.f155936b);
        return this.f155936b.B();
    }

    @Override // vz.a
    public vz.a v(a.d dVar) {
        this.f155935a = (d) dVar;
        return this;
    }

    @Override // vz.a
    public vz.a w(String str) {
        f.o(str, "userAgent");
        this.f155935a.j("User-Agent", str);
        return this;
    }

    @Override // vz.a
    public vz.a x(String str) {
        f.l(str, "url");
        try {
            this.f155935a.i(new URL(Q(str)));
            return this;
        } catch (MalformedURLException e10) {
            throw new IllegalArgumentException(String.format("The supplied URL, '%s', is malformed. Make sure it is an absolute URL, and starts with 'http://' or 'https://'. See https://jsoup.org/cookbook/extracting-data/working-with-urls", str), e10);
        }
    }

    @Override // vz.a
    public a.e y() {
        a.e eVar = this.f155936b;
        if (eVar != null) {
            return eVar;
        }
        throw new IllegalArgumentException("You must execute the request before getting a response.");
    }

    @Override // vz.a
    public vz.a z(CookieStore cookieStore) {
        this.f155935a.f155958r = new CookieManager(cookieStore, null);
        return this;
    }

    /* compiled from: HttpConnection */
    public static abstract class b<T extends a.AbstractC1234a<T>> implements a.AbstractC1234a<T> {

        /* renamed from: e  reason: collision with root package name */
        public static final URL f155937e;

        /* renamed from: a  reason: collision with root package name */
        public URL f155938a;

        /* renamed from: b  reason: collision with root package name */
        public a.c f155939b;

        /* renamed from: c  reason: collision with root package name */
        public Map<String, List<String>> f155940c;

        /* renamed from: d  reason: collision with root package name */
        public Map<String, String> f155941d;

        static {
            try {
                f155937e = new URL("http://undefined/");
            } catch (MalformedURLException e10) {
                throw new IllegalStateException(e10);
            }
        }

        public static String U(String str) {
            byte[] bytes = str.getBytes(e.f155934l);
            if (!W(bytes)) {
                return str;
            }
            return new String(bytes, e.f155933k);
        }

        public static boolean W(byte[] bArr) {
            int i10;
            int i11 = 3;
            if (!(bArr.length >= 3 && (bArr[0] & 255) == 239 && (bArr[1] & 255) == 187 && (bArr[2] & 255) == 191)) {
                i11 = 0;
            }
            int length = bArr.length;
            while (i11 < length) {
                byte b10 = bArr[i11];
                if ((b10 & 128) != 0) {
                    if ((b10 & 224) == 192) {
                        i10 = i11 + 1;
                    } else if ((b10 & 240) == 224) {
                        i10 = i11 + 2;
                    } else if ((b10 & 248) != 240) {
                        return false;
                    } else {
                        i10 = i11 + 3;
                    }
                    if (i10 >= bArr.length) {
                        return false;
                    }
                    while (i11 < i10) {
                        i11++;
                        if ((bArr[i11] & w1.a.f146754s7) != 128) {
                            return false;
                        }
                    }
                    continue;
                }
                i11++;
            }
            return true;
        }

        @Override // vz.a.AbstractC1234a
        public boolean C(String str) {
            f.l(str, "name");
            return this.f155941d.containsKey(str);
        }

        @Override // vz.a.AbstractC1234a
        public T D(String str) {
            f.l(str, "name");
            Map.Entry<String, List<String>> X = X(str);
            if (X != null) {
                this.f155940c.remove(X.getKey());
            }
            return this;
        }

        @Override // vz.a.AbstractC1234a
        public String E(String str) {
            f.o(str, "name");
            List<String> V = V(str);
            if (V.size() > 0) {
                return f.k(V, ", ");
            }
            return null;
        }

        @Override // vz.a.AbstractC1234a
        public boolean F(String str) {
            f.l(str, "name");
            return !V(str).isEmpty();
        }

        @Override // vz.a.AbstractC1234a
        public T I(String str) {
            f.l(str, "name");
            this.f155941d.remove(str);
            return this;
        }

        @Override // vz.a.AbstractC1234a
        public List<String> K(String str) {
            f.l(str, "name");
            return V(str);
        }

        @Override // vz.a.AbstractC1234a
        public Map<String, List<String>> L() {
            return this.f155940c;
        }

        @Override // vz.a.AbstractC1234a
        public Map<String, String> N() {
            LinkedHashMap linkedHashMap = new LinkedHashMap(this.f155940c.size());
            for (Map.Entry<String, List<String>> entry : this.f155940c.entrySet()) {
                String key = entry.getKey();
                List<String> value = entry.getValue();
                if (value.size() > 0) {
                    linkedHashMap.put(key, value.get(0));
                }
            }
            return linkedHashMap;
        }

        public final List<String> V(String str) {
            f.m(str);
            for (Map.Entry<String, List<String>> entry : this.f155940c.entrySet()) {
                if (str.equalsIgnoreCase(entry.getKey())) {
                    return entry.getValue();
                }
            }
            return Collections.emptyList();
        }

        @Nullable
        public final Map.Entry<String, List<String>> X(String str) {
            String a10 = xz.d.a(str);
            for (Map.Entry<String, List<String>> entry : this.f155940c.entrySet()) {
                if (xz.d.a(entry.getKey()).equals(a10)) {
                    return entry;
                }
            }
            return null;
        }

        @Override // vz.a.AbstractC1234a
        public T addHeader(String str, String str2) {
            f.l(str, "name");
            if (str2 == null) {
                str2 = "";
            }
            List<String> K = K(str);
            if (K.isEmpty()) {
                K = new ArrayList<>();
                this.f155940c.put(str, K);
            }
            K.add(U(str2));
            return this;
        }

        @Override // vz.a.AbstractC1234a
        public T c(String str, String str2) {
            f.l(str, "name");
            f.o(str2, "value");
            this.f155941d.put(str, str2);
            return this;
        }

        @Override // vz.a.AbstractC1234a
        public T i(URL url) {
            f.o(url, "url");
            this.f155938a = e.T(url);
            return this;
        }

        @Override // vz.a.AbstractC1234a
        public T j(String str, String str2) {
            f.l(str, "name");
            D(str);
            addHeader(str, str2);
            return this;
        }

        @Override // vz.a.AbstractC1234a
        public a.c method() {
            return this.f155939b;
        }

        @Override // vz.a.AbstractC1234a
        public T p(a.c cVar) {
            f.o(cVar, "method");
            this.f155939b = cVar;
            return this;
        }

        @Override // vz.a.AbstractC1234a
        public URL u() {
            URL url = this.f155938a;
            if (url != f155937e) {
                return url;
            }
            throw new IllegalArgumentException("URL not set. Make sure to call #url(...) before executing the request.");
        }

        @Override // vz.a.AbstractC1234a
        public boolean v(String str, String str2) {
            f.j(str);
            f.j(str2);
            for (String str3 : K(str)) {
                if (str2.equalsIgnoreCase(str3)) {
                    return true;
                }
            }
            return false;
        }

        @Override // vz.a.AbstractC1234a
        public Map<String, String> y() {
            return this.f155941d;
        }

        @Override // vz.a.AbstractC1234a
        public String z(String str) {
            f.l(str, "name");
            return this.f155941d.get(str);
        }

        public b() {
            this.f155938a = f155937e;
            this.f155939b = a.c.GET;
            this.f155940c = new LinkedHashMap();
            this.f155941d = new LinkedHashMap();
        }

        public b(b<T> bVar) {
            this.f155938a = f155937e;
            this.f155939b = a.c.GET;
            this.f155938a = bVar.f155938a;
            this.f155939b = bVar.f155939b;
            this.f155940c = new LinkedHashMap();
            for (Map.Entry<String, List<String>> entry : bVar.f155940c.entrySet()) {
                this.f155940c.put(entry.getKey(), new ArrayList(entry.getValue()));
            }
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            this.f155941d = linkedHashMap;
            linkedHashMap.putAll(bVar.f155941d);
        }
    }

    public e() {
        this.f155935a = new d();
    }

    public e(d dVar) {
        this.f155935a = new d(dVar);
    }

    public e(d dVar, C1260e eVar) {
        this.f155935a = dVar;
        this.f155936b = eVar;
    }

    /* renamed from: wz.e$e  reason: collision with other inner class name */
    /* compiled from: HttpConnection */
    public static class C1260e extends b<a.e> implements a.e {

        /* renamed from: q  reason: collision with root package name */
        public static final int f155960q = 20;

        /* renamed from: r  reason: collision with root package name */
        public static final String f155961r = "Location";

        /* renamed from: s  reason: collision with root package name */
        public static final Pattern f155962s = Pattern.compile("(application|text)/\\w*\\+?xml.*");

        /* renamed from: f  reason: collision with root package name */
        public final int f155963f;

        /* renamed from: g  reason: collision with root package name */
        public final String f155964g;
        @Nullable

        /* renamed from: h  reason: collision with root package name */
        public ByteBuffer f155965h;
        @Nullable

        /* renamed from: i  reason: collision with root package name */
        public InputStream f155966i;
        @Nullable

        /* renamed from: j  reason: collision with root package name */
        public HttpURLConnection f155967j;
        @Nullable

        /* renamed from: k  reason: collision with root package name */
        public String f155968k;
        @Nullable

        /* renamed from: l  reason: collision with root package name */
        public final String f155969l;

        /* renamed from: m  reason: collision with root package name */
        public boolean f155970m;

        /* renamed from: n  reason: collision with root package name */
        public boolean f155971n;

        /* renamed from: o  reason: collision with root package name */
        public int f155972o;

        /* renamed from: p  reason: collision with root package name */
        public final d f155973p;

        public C1260e() {
            super();
            this.f155970m = false;
            this.f155971n = false;
            this.f155972o = 0;
            this.f155963f = 400;
            this.f155964g = "Request not made";
            this.f155973p = new d();
            this.f155969l = null;
        }

        public static HttpURLConnection Z(d dVar) throws IOException {
            URLConnection uRLConnection;
            Proxy x10 = dVar.x();
            if (x10 == null) {
                uRLConnection = dVar.u().openConnection();
            } else {
                uRLConnection = dVar.u().openConnection(x10);
            }
            HttpURLConnection httpURLConnection = (HttpURLConnection) uRLConnection;
            httpURLConnection.setRequestMethod(dVar.method().name());
            httpURLConnection.setInstanceFollowRedirects(false);
            httpURLConnection.setConnectTimeout(dVar.timeout());
            httpURLConnection.setReadTimeout(dVar.timeout() / 2);
            if (dVar.w() != null && (httpURLConnection instanceof HttpsURLConnection)) {
                ((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(dVar.w());
            }
            if (dVar.method().hasBody()) {
                httpURLConnection.setDoOutput(true);
            }
            c.a(dVar, httpURLConnection);
            for (Map.Entry entry : dVar.L().entrySet()) {
                for (String str : (List) entry.getValue()) {
                    httpURLConnection.addRequestProperty((String) entry.getKey(), str);
                }
            }
            return httpURLConnection;
        }

        public static LinkedHashMap<String, List<String>> a0(HttpURLConnection httpURLConnection) {
            LinkedHashMap<String, List<String>> linkedHashMap = new LinkedHashMap<>();
            int i10 = 0;
            while (true) {
                String headerFieldKey = httpURLConnection.getHeaderFieldKey(i10);
                String headerField = httpURLConnection.getHeaderField(i10);
                if (headerFieldKey == null && headerField == null) {
                    return linkedHashMap;
                }
                i10++;
                if (!(headerFieldKey == null || headerField == null)) {
                    if (linkedHashMap.containsKey(headerFieldKey)) {
                        linkedHashMap.get(headerFieldKey).add(headerField);
                    } else {
                        ArrayList arrayList = new ArrayList();
                        arrayList.add(headerField);
                        linkedHashMap.put(headerFieldKey, arrayList);
                    }
                }
            }
        }

        public static C1260e b0(d dVar) throws IOException {
            return c0(dVar, null);
        }

        /* JADX WARNING: Removed duplicated region for block: B:103:0x01fc A[SYNTHETIC, Splitter:B:103:0x01fc] */
        /* JADX WARNING: Removed duplicated region for block: B:28:0x0092 A[Catch:{ IOException -> 0x01f9 }] */
        public static C1260e c0(d dVar, @Nullable C1260e eVar) throws IOException {
            String str;
            HttpURLConnection Z;
            IOException e10;
            int responseCode;
            C1260e eVar2;
            synchronized (dVar) {
                f.e(dVar.f155959s, "Multiple threads were detected trying to execute the same request concurrently. Make sure to use Connection#newRequest() and do not share an executing request between threads.");
                dVar.f155959s = true;
            }
            f.o(dVar, HiAnalyticsConstant.Direction.REQUEST);
            URL u10 = dVar.u();
            f.n(u10, "URL must be specified to connect");
            String protocol = u10.getProtocol();
            if (protocol.equals("http") || protocol.equals("https")) {
                boolean hasBody = dVar.method().hasBody();
                boolean z10 = dVar.P() != null;
                if (!hasBody) {
                    f.e(z10, "Cannot set a request body for HTTP method " + dVar.method());
                }
                C1260e eVar3 = null;
                if (dVar.e().size() > 0 && (!hasBody || z10)) {
                    g0(dVar);
                } else if (hasBody) {
                    str = h0(dVar);
                    long nanoTime = System.nanoTime();
                    Z = Z(dVar);
                    Z.connect();
                    if (Z.getDoOutput()) {
                        OutputStream outputStream = Z.getOutputStream();
                        try {
                            i0(dVar, outputStream, str);
                            outputStream.close();
                        } catch (IOException e11) {
                            Z.disconnect();
                            throw e11;
                        } catch (Throwable th2) {
                            outputStream.close();
                            throw th2;
                        }
                    }
                    responseCode = Z.getResponseCode();
                    eVar2 = new C1260e(Z, dVar, eVar);
                    try {
                        if (!eVar2.F("Location") && dVar.A()) {
                            if (responseCode != 307) {
                                dVar.p(a.c.GET);
                                dVar.e().clear();
                                dVar.b(null);
                                dVar.D("Content-Type");
                            }
                            String E = eVar2.E("Location");
                            f.m(E);
                            if (E.startsWith("http:/") && E.charAt(6) != '/') {
                                E = E.substring(6);
                            }
                            dVar.i(e.R(f.s(dVar.u(), E)));
                            dVar.f155959s = false;
                            C1260e c02 = c0(dVar, eVar2);
                            dVar.f155959s = false;
                            return c02;
                        } else if ((responseCode >= 200 || responseCode >= 400) && !dVar.q()) {
                            throw new vz.b("HTTP error fetching URL", responseCode, dVar.u().toString());
                        } else {
                            String contentType = eVar2.contentType();
                            if (contentType == null || dVar.H() || contentType.startsWith("text/") || f155962s.matcher(contentType).matches()) {
                                if (contentType != null && f155962s.matcher(contentType).matches() && !dVar.f155955o) {
                                    dVar.l(g.v());
                                }
                                eVar2.f155968k = d.d(eVar2.f155969l);
                                if (Z.getContentLength() == 0 || dVar.method() == a.c.HEAD) {
                                    eVar2.f155965h = d.c();
                                } else {
                                    InputStream errorStream = Z.getErrorStream() != null ? Z.getErrorStream() : Z.getInputStream();
                                    eVar2.f155966i = errorStream;
                                    f.m(errorStream);
                                    if (eVar2.v("Content-Encoding", BaseRequest.CONTENT_ENCODING_GZIP)) {
                                        eVar2.f155966i = new GZIPInputStream(eVar2.f155966i);
                                    } else if (eVar2.v("Content-Encoding", "deflate")) {
                                        eVar2.f155966i = new InflaterInputStream(eVar2.f155966i, new Inflater(true));
                                    }
                                    eVar2.f155966i = xz.a.d(eVar2.f155966i, 32768, dVar.Q()).c(nanoTime, (long) dVar.timeout());
                                }
                                dVar.f155959s = false;
                                eVar2.f155970m = true;
                                return eVar2;
                            }
                            throw new vz.f("Unhandled content type. Must be text/*, application/xml, or application/*+xml", contentType, dVar.u().toString());
                        }
                    } catch (IOException e12) {
                        e10 = e12;
                        eVar3 = eVar2;
                        if (eVar3 != null) {
                        }
                        throw e10;
                    }
                }
                str = null;
                long nanoTime2 = System.nanoTime();
                Z = Z(dVar);
                try {
                    Z.connect();
                    if (Z.getDoOutput()) {
                    }
                    responseCode = Z.getResponseCode();
                    eVar2 = new C1260e(Z, dVar, eVar);
                    if (!eVar2.F("Location")) {
                    }
                    if (responseCode >= 200) {
                    }
                    throw new vz.b("HTTP error fetching URL", responseCode, dVar.u().toString());
                } catch (IOException e13) {
                    e10 = e13;
                    if (eVar3 != null) {
                        try {
                            eVar3.f0();
                        } catch (Throwable th3) {
                            dVar.f155959s = false;
                            throw th3;
                        }
                    }
                    throw e10;
                }
            } else {
                throw new MalformedURLException("Only http & https protocols supported");
            }
        }

        public static void g0(a.d dVar) throws IOException {
            boolean z10;
            URL u10 = dVar.u();
            StringBuilder b10 = f.b();
            b10.append(u10.getProtocol());
            b10.append("://");
            b10.append(u10.getAuthority());
            b10.append(u10.getPath());
            b10.append("?");
            if (u10.getQuery() != null) {
                b10.append(u10.getQuery());
                z10 = false;
            } else {
                z10 = true;
            }
            for (a.b bVar : dVar.e()) {
                f.e(bVar.e(), "InputStream data not supported in URL query string.");
                if (!z10) {
                    b10.append(h0.f157456d);
                } else {
                    z10 = false;
                }
                String key = bVar.key();
                String str = d.f155918c;
                b10.append(URLEncoder.encode(key, str));
                b10.append(l4.a.f83696h);
                b10.append(URLEncoder.encode(bVar.value(), str));
            }
            dVar.i(new URL(f.q(b10)));
            dVar.e().clear();
        }

        @Nullable
        public static String h0(a.d dVar) {
            String E = dVar.E("Content-Type");
            if (E != null) {
                if (E.contains("multipart/form-data") && !E.contains("boundary")) {
                    String i10 = d.i();
                    dVar.j("Content-Type", "multipart/form-data; boundary=" + i10);
                    return i10;
                }
            } else if (e.S(dVar)) {
                String i11 = d.i();
                dVar.j("Content-Type", "multipart/form-data; boundary=" + i11);
                return i11;
            } else {
                dVar.j("Content-Type", "application/x-www-form-urlencoded; charset=" + dVar.s());
            }
            return null;
        }

        public static void i0(a.d dVar, OutputStream outputStream, @Nullable String str) throws IOException {
            Collection<a.b> e10 = dVar.e();
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, Charset.forName(dVar.s())));
            if (str != null) {
                for (a.b bVar : e10) {
                    bufferedWriter.write("--");
                    bufferedWriter.write(str);
                    bufferedWriter.write(IOUtils.LINE_SEPARATOR_WINDOWS);
                    bufferedWriter.write("Content-Disposition: form-data; name=\"");
                    bufferedWriter.write(e.P(bVar.key()));
                    bufferedWriter.write("\"");
                    InputStream inputStream = bVar.inputStream();
                    if (inputStream != null) {
                        bufferedWriter.write("; filename=\"");
                        bufferedWriter.write(e.P(bVar.value()));
                        bufferedWriter.write("\"\r\nContent-Type: ");
                        String contentType = bVar.contentType();
                        if (contentType == null) {
                            contentType = "application/octet-stream";
                        }
                        bufferedWriter.write(contentType);
                        bufferedWriter.write("\r\n\r\n");
                        bufferedWriter.flush();
                        d.a(inputStream, outputStream);
                        outputStream.flush();
                    } else {
                        bufferedWriter.write("\r\n\r\n");
                        bufferedWriter.write(bVar.value());
                    }
                    bufferedWriter.write(IOUtils.LINE_SEPARATOR_WINDOWS);
                }
                bufferedWriter.write("--");
                bufferedWriter.write(str);
                bufferedWriter.write("--");
            } else {
                String P = dVar.P();
                if (P != null) {
                    bufferedWriter.write(P);
                } else {
                    boolean z10 = true;
                    for (a.b bVar2 : e10) {
                        if (!z10) {
                            bufferedWriter.append(h0.f157456d);
                        } else {
                            z10 = false;
                        }
                        bufferedWriter.write(URLEncoder.encode(bVar2.key(), dVar.s()));
                        bufferedWriter.write(61);
                        bufferedWriter.write(URLEncoder.encode(bVar2.value(), dVar.s()));
                    }
                }
            }
            bufferedWriter.close();
        }

        @Override // vz.a.e
        public yz.f B() throws IOException {
            f.g(this.f155970m, "Request must be executed (with .execute(), .get(), or .post() before parsing response");
            if (this.f155965h != null) {
                this.f155966i = new ByteArrayInputStream(this.f155965h.array());
                this.f155971n = false;
            }
            f.e(this.f155971n, "Input stream already read and parsed, cannot re-read.");
            yz.f j10 = d.j(this.f155966i, this.f155968k, this.f155938a.toExternalForm(), this.f155973p.T());
            j10.W2(new e(this.f155973p, this));
            this.f155968k = j10.h3().a().name();
            this.f155971n = true;
            f0();
            return j10;
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ boolean C(String str) {
            return super.C(str);
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.e D(String str) {
            return super.D(str);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ String E(String str) {
            return super.E(str);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ boolean F(String str) {
            return super.F(str);
        }

        @Override // vz.a.e
        public String G() {
            return this.f155968k;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.e I(String str) {
            return super.I(str);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ List K(String str) {
            return super.K(str);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ Map L() {
            return super.L();
        }

        @Override // vz.a.e
        public a.e M() {
            d0();
            return this;
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ Map N() {
            return super.N();
        }

        @Override // vz.a.e
        public int O() {
            return this.f155963f;
        }

        @Override // vz.a.e
        public String R() {
            return this.f155964g;
        }

        @Override // vz.a.e
        public byte[] S() {
            d0();
            f.m(this.f155965h);
            return this.f155965h.array();
        }

        /* renamed from: Y */
        public C1260e J(String str) {
            this.f155968k = str;
            return this;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.e addHeader(String str, String str2) {
            return super.addHeader(str, str2);
        }

        @Override // vz.a.e
        public String body() {
            d0();
            f.m(this.f155965h);
            String str = this.f155968k;
            String charBuffer = (str == null ? d.f155917b : Charset.forName(str)).decode(this.f155965h).toString();
            this.f155965h.rewind();
            return charBuffer;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.e c(String str, String str2) {
            return super.c(str, str2);
        }

        @Override // vz.a.e
        public String contentType() {
            return this.f155969l;
        }

        public final void d0() {
            f.g(this.f155970m, "Request must be executed (with .execute(), .get(), or .post() before getting response body");
            if (this.f155966i != null && this.f155965h == null) {
                f.e(this.f155971n, "Request has already been read (with .parse())");
                try {
                    this.f155965h = d.k(this.f155966i, this.f155973p.Q());
                    this.f155971n = true;
                    f0();
                } catch (IOException e10) {
                    throw new vz.e(e10);
                } catch (Throwable th2) {
                    this.f155971n = true;
                    f0();
                    throw th2;
                }
            }
        }

        public void e0(Map<String, List<String>> map) {
            for (Map.Entry<String, List<String>> entry : map.entrySet()) {
                String key = entry.getKey();
                if (key != null) {
                    List<String> value = entry.getValue();
                    if (key.equalsIgnoreCase(HttpHeaders.SET_COOKIE)) {
                        for (String str : value) {
                            if (str != null) {
                                j jVar = new j(str);
                                String trim = jVar.d(ContainerUtils.KEY_VALUE_DELIMITER).trim();
                                String trim2 = jVar.j(h.f134437b).trim();
                                if (trim.length() > 0 && !this.f155941d.containsKey(trim)) {
                                    c(trim, trim2);
                                }
                            }
                        }
                    }
                    for (String str2 : value) {
                        addHeader(key, str2);
                    }
                }
            }
        }

        public final void f0() {
            InputStream inputStream = this.f155966i;
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException unused) {
                } catch (Throwable th2) {
                    this.f155966i = null;
                    throw th2;
                }
                this.f155966i = null;
            }
            HttpURLConnection httpURLConnection = this.f155967j;
            if (httpURLConnection != null) {
                httpURLConnection.disconnect();
                this.f155967j = null;
            }
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.e i(URL url) {
            return super.i(url);
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.e j(String str, String str2) {
            return super.j(str, str2);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.c method() {
            return super.method();
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.e p(a.c cVar) {
            return super.p(cVar);
        }

        @Override // vz.a.e
        public BufferedInputStream t() {
            f.g(this.f155970m, "Request must be executed (with .execute(), .get(), or .post() before getting response body");
            f.e(this.f155971n, "Request has already been read");
            this.f155971n = true;
            return xz.a.d(this.f155966i, 32768, this.f155973p.Q());
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ URL u() {
            return super.u();
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ boolean v(String str, String str2) {
            return super.v(str, str2);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ Map y() {
            return super.y();
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ String z(String str) {
            return super.z(str);
        }

        public C1260e(HttpURLConnection httpURLConnection, d dVar, @Nullable C1260e eVar) throws IOException {
            super();
            this.f155970m = false;
            this.f155971n = false;
            this.f155972o = 0;
            this.f155967j = httpURLConnection;
            this.f155973p = dVar;
            this.f155939b = a.c.valueOf(httpURLConnection.getRequestMethod());
            this.f155938a = httpURLConnection.getURL();
            this.f155963f = httpURLConnection.getResponseCode();
            this.f155964g = httpURLConnection.getResponseMessage();
            this.f155969l = httpURLConnection.getContentType();
            LinkedHashMap<String, List<String>> a02 = a0(httpURLConnection);
            e0(a02);
            c.d(dVar, this.f155938a, a02);
            if (eVar != null) {
                for (Map.Entry entry : eVar.y().entrySet()) {
                    if (!C((String) entry.getKey())) {
                        c((String) entry.getKey(), (String) entry.getValue());
                    }
                }
                eVar.f0();
                int i10 = eVar.f155972o + 1;
                this.f155972o = i10;
                if (i10 >= 20) {
                    throw new IOException(String.format("Too many redirects occurred trying to load URL %s", eVar.u()));
                }
            }
        }
    }

    /* compiled from: HttpConnection */
    public static class d extends b<a.d> implements a.d {
        @Nullable

        /* renamed from: f  reason: collision with root package name */
        public Proxy f155946f;

        /* renamed from: g  reason: collision with root package name */
        public int f155947g;

        /* renamed from: h  reason: collision with root package name */
        public int f155948h;

        /* renamed from: i  reason: collision with root package name */
        public boolean f155949i;

        /* renamed from: j  reason: collision with root package name */
        public final Collection<a.b> f155950j;
        @Nullable

        /* renamed from: k  reason: collision with root package name */
        public String f155951k;

        /* renamed from: l  reason: collision with root package name */
        public boolean f155952l;

        /* renamed from: m  reason: collision with root package name */
        public boolean f155953m;

        /* renamed from: n  reason: collision with root package name */
        public g f155954n;

        /* renamed from: o  reason: collision with root package name */
        public boolean f155955o;

        /* renamed from: p  reason: collision with root package name */
        public String f155956p;
        @Nullable

        /* renamed from: q  reason: collision with root package name */
        public SSLSocketFactory f155957q;

        /* renamed from: r  reason: collision with root package name */
        public CookieManager f155958r;

        /* renamed from: s  reason: collision with root package name */
        public volatile boolean f155959s;

        static {
            System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
        }

        public d() {
            super();
            this.f155951k = null;
            this.f155952l = false;
            this.f155953m = false;
            this.f155955o = false;
            this.f155956p = d.f155918c;
            this.f155959s = false;
            this.f155947g = 30000;
            this.f155948h = 2097152;
            this.f155949i = true;
            this.f155950j = new ArrayList();
            this.f155939b = a.c.GET;
            addHeader("Accept-Encoding", BaseRequest.CONTENT_ENCODING_GZIP);
            addHeader("User-Agent", e.f155926d);
            this.f155954n = g.c();
            this.f155958r = new CookieManager();
        }

        @Override // vz.a.d
        public boolean A() {
            return this.f155949i;
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ boolean C(String str) {
            return super.C(str);
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.d D(String str) {
            return super.D(str);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ String E(String str) {
            return super.E(str);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ boolean F(String str) {
            return super.F(str);
        }

        @Override // vz.a.d
        public boolean H() {
            return this.f155953m;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.d I(String str) {
            return super.I(str);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ List K(String str) {
            return super.K(str);
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ Map L() {
            return super.L();
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ Map N() {
            return super.N();
        }

        @Override // vz.a.d
        public String P() {
            return this.f155951k;
        }

        @Override // vz.a.d
        public int Q() {
            return this.f155948h;
        }

        @Override // vz.a.d
        public g T() {
            return this.f155954n;
        }

        @Override // vz.a.d
        public a.d a(boolean z10) {
            this.f155949i = z10;
            return this;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.d addHeader(String str, String str2) {
            return super.addHeader(str, str2);
        }

        @Override // vz.a.d
        public a.d b(@Nullable String str) {
            this.f155951k = str;
            return this;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.d c(String str, String str2) {
            return super.c(str, str2);
        }

        public CookieManager d0() {
            return this.f155958r;
        }

        @Override // vz.a.d
        public Collection<a.b> e() {
            return this.f155950j;
        }

        /* renamed from: e0 */
        public d r(a.b bVar) {
            f.o(bVar, "keyval");
            this.f155950j.add(bVar);
            return this;
        }

        @Override // vz.a.d
        public void f(SSLSocketFactory sSLSocketFactory) {
            this.f155957q = sSLSocketFactory;
        }

        /* renamed from: f0 */
        public d l(g gVar) {
            this.f155954n = gVar;
            this.f155955o = true;
            return this;
        }

        @Override // vz.a.d
        public a.d g(String str) {
            f.o(str, "charset");
            if (Charset.isSupported(str)) {
                this.f155956p = str;
                return this;
            }
            throw new IllegalCharsetNameException(str);
        }

        /* renamed from: g0 */
        public d k(String str, int i10) {
            this.f155946f = new Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved(str, i10));
            return this;
        }

        /* renamed from: h0 */
        public d h(@Nullable Proxy proxy) {
            this.f155946f = proxy;
            return this;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.d i(URL url) {
            return super.i(url);
        }

        /* renamed from: i0 */
        public d d(int i10) {
            f.g(i10 >= 0, "Timeout milliseconds must be 0 (infinite) or greater");
            this.f155947g = i10;
            return this;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.d j(String str, String str2) {
            return super.j(str, str2);
        }

        @Override // vz.a.d
        public a.d m(int i10) {
            f.g(i10 >= 0, "maxSize must be 0 (unlimited) or larger");
            this.f155948h = i10;
            return this;
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.c method() {
            return super.method();
        }

        @Override // vz.a.d
        public a.d n(boolean z10) {
            this.f155952l = z10;
            return this;
        }

        @Override // vz.a.d
        public a.d o(boolean z10) {
            this.f155953m = z10;
            return this;
        }

        /* Return type fixed from 'vz.a$a' to match base method */
        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ a.d p(a.c cVar) {
            return super.p(cVar);
        }

        @Override // vz.a.d
        public boolean q() {
            return this.f155952l;
        }

        @Override // vz.a.d
        public String s() {
            return this.f155956p;
        }

        @Override // vz.a.d
        public int timeout() {
            return this.f155947g;
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ URL u() {
            return super.u();
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ boolean v(String str, String str2) {
            return super.v(str, str2);
        }

        @Override // vz.a.d
        public SSLSocketFactory w() {
            return this.f155957q;
        }

        @Override // vz.a.d
        public Proxy x() {
            return this.f155946f;
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ Map y() {
            return super.y();
        }

        @Override // wz.e.b, vz.a.AbstractC1234a
        public /* bridge */ /* synthetic */ String z(String str) {
            return super.z(str);
        }

        public d(d dVar) {
            super(dVar);
            this.f155951k = null;
            this.f155952l = false;
            this.f155953m = false;
            this.f155955o = false;
            this.f155956p = d.f155918c;
            this.f155959s = false;
            this.f155946f = dVar.f155946f;
            this.f155956p = dVar.f155956p;
            this.f155947g = dVar.f155947g;
            this.f155948h = dVar.f155948h;
            this.f155949i = dVar.f155949i;
            ArrayList arrayList = new ArrayList();
            this.f155950j = arrayList;
            arrayList.addAll(dVar.e());
            this.f155951k = dVar.f155951k;
            this.f155952l = dVar.f155952l;
            this.f155953m = dVar.f155953m;
            this.f155954n = dVar.f155954n.g();
            this.f155955o = dVar.f155955o;
            this.f155957q = dVar.f155957q;
            this.f155958r = dVar.f155958r;
            this.f155959s = false;
        }
    }
}