花瓣 v4.6.12版本的 MD5 值为:6a3515d4d16d98931f1b3d25a91b257e

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


package org.jsoup.helper;

import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField;
import com.efs.sdk.base.Constants;
import com.google.android.exoplayer2.u2;
import com.huawei.hms.framework.common.ContainerUtils;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
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 kotlin.h3.h0;
import org.apache.commons.cli.HelpFormatter;
import org.jsoup.HttpStatusException;
import org.jsoup.UncheckedIOException;
import org.jsoup.UnsupportedMimeTypeException;
import org.jsoup.a;
import org.jsoup.d.m;
import org.jsoup.f.j;
public class e implements org.jsoup.a {
    public static final String c = "Content-Encoding";
    public static final String f16389d = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36";
    private static final String f16390e = "User-Agent";
    public static final String f16391f = "Content-Type";
    public static final String f16392g = "multipart/form-data";
    public static final String f16393h = "application/x-www-form-urlencoded";
    private static final int f16394i = 307;
    private static final String j = "application/octet-stream";
    private static final Charset k = Charset.forName("UTF-8");
    private static final Charset l = Charset.forName(u2.p);
    private d a;
    @Nullable
    private a.e b;

    public static class c implements a.b {
        private String a;
        private String b;
        @Nullable
        private InputStream c;
        @Nullable
        private String f16397d;

        private c(String str, String str2) {
            f.m(str, "key");
            f.p(str2, com.ubixnow.utils.monitor.data.adapter.c.w);
            this.a = str;
            this.b = str2;
        }

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

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

        @Override
        public String a() {
            return this.a;
        }

        @Override
        public c i(InputStream inputStream) {
            f.p(this.b, "inputStream");
            this.c = inputStream;
            return this;
        }

        @Override
        public String e() {
            return this.f16397d;
        }

        @Override
        public a.b f(String str) {
            f.k(str);
            this.f16397d = str;
            return this;
        }

        @Override
        public InputStream inputStream() {
            return this.c;
        }

        @Override
        public boolean j() {
            return this.c != null;
        }

        @Override
        public c g(String str) {
            f.m(str, "key");
            this.a = str;
            return this;
        }

        @Override
        public c h(String str) {
            f.p(str, com.ubixnow.utils.monitor.data.adapter.c.w);
            this.b = str;
            return this;
        }

        public String toString() {
            return this.a + ContainerUtils.KEY_VALUE_DELIMITER + this.b;
        }

        @Override
        public String value() {
            return this.b;
        }
    }

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

    public static org.jsoup.a O(URL url) {
        e eVar = new e();
        eVar.j(url);
        return eVar;
    }

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

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

    static URL R(URL url) {
        URL T = T(url);
        try {
            return new URI(T.getProtocol(), T.getUserInfo(), T.getHost(), T.getPort(), T.getPath(), T.getQuery(), T.getRef()).toURL();
        } catch (MalformedURLException | URISyntaxException unused) {
            return T;
        }
    }

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

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

    @Override
    public CookieStore A() {
        return this.a.r.getCookieStore();
    }

    @Override
    public org.jsoup.a B(String str) {
        f.p(str, "referrer");
        this.a.k(e.e.b.h.d.J, str);
        return this;
    }

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

    @Override
    public org.jsoup.a D(String str, String str2, InputStream inputStream) {
        this.a.x(c.c(str, str2, inputStream));
        return this;
    }

    @Override
    public org.jsoup.a E(a.e eVar) {
        this.b = eVar;
        return this;
    }

    @Override
    public org.jsoup.a F(String... strArr) {
        f.p(strArr, "keyvals");
        f.h(strArr.length % 2 == 0, "Must supply an even number of key value pairs");
        for (int i2 = 0; i2 < strArr.length; i2 += 2) {
            String str = strArr[i2];
            String str2 = strArr[i2 + 1];
            f.l(str, "Data key must not be empty");
            f.o(str2, "Data value must not be null");
            this.a.x(c.b(str, str2));
        }
        return this;
    }

    @Override
    public a.b G(String str) {
        f.m(str, "key");
        for (a.b bVar : request().w()) {
            if (bVar.a().equals(str)) {
                return bVar;
            }
        }
        return null;
    }

    @Override
    public org.jsoup.a H(Map<String, String> map) {
        f.p(map, "data");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            this.a.x(c.b(entry.getKey(), entry.getValue()));
        }
        return this;
    }

    @Override
    public org.jsoup.a a(boolean z) {
        this.a.a(z);
        return this;
    }

    @Override
    public org.jsoup.a b(String str) {
        this.a.b(str);
        return this;
    }

    @Override
    public org.jsoup.a c(String str, String str2) {
        this.a.c(str, str2);
        return this;
    }

    @Override
    public org.jsoup.a d(int i2) {
        this.a.d(i2);
        return this;
    }

    @Override
    public org.jsoup.a e(Collection<a.b> collection) {
        f.p(collection, "data");
        for (a.b bVar : collection) {
            this.a.x(bVar);
        }
        return this;
    }

    @Override
    public a.e execute() throws IOException {
        C1088e a0 = C1088e.a0(this.a);
        this.b = a0;
        return a0;
    }

    @Override
    public org.jsoup.a f(SSLSocketFactory sSLSocketFactory) {
        this.a.f(sSLSocketFactory);
        return this;
    }

    @Override
    public org.jsoup.a g(String str) {
        this.a.g(str);
        return this;
    }

    @Override
    public m get() throws IOException {
        this.a.l(a.c.GET);
        execute();
        f.n(this.b);
        return this.b.B();
    }

    @Override
    public org.jsoup.a h(@Nullable Proxy proxy) {
        this.a.h(proxy);
        return this;
    }

    @Override
    public org.jsoup.a i(org.jsoup.f.g gVar) {
        this.a.i(gVar);
        return this;
    }

    @Override
    public org.jsoup.a j(URL url) {
        this.a.j(url);
        return this;
    }

    @Override
    public org.jsoup.a k(String str, String str2) {
        this.a.k(str, str2);
        return this;
    }

    @Override
    public org.jsoup.a l(a.c cVar) {
        this.a.l(cVar);
        return this;
    }

    @Override
    public org.jsoup.a m(String str, int i2) {
        this.a.m(str, i2);
        return this;
    }

    @Override
    public org.jsoup.a n(int i2) {
        this.a.n(i2);
        return this;
    }

    @Override
    public org.jsoup.a o(boolean z) {
        this.a.o(z);
        return this;
    }

    @Override
    public org.jsoup.a p(boolean z) {
        this.a.p(z);
        return this;
    }

    @Override
    public org.jsoup.a q(Map<String, String> map) {
        f.p(map, "headers");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            this.a.k(entry.getKey(), entry.getValue());
        }
        return this;
    }

    @Override
    public org.jsoup.a r(String str, String str2, InputStream inputStream, String str3) {
        this.a.x(c.c(str, str2, inputStream).f(str3));
        return this;
    }

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

    @Override
    public org.jsoup.a s() {
        return new e(this.a);
    }

    @Override
    public org.jsoup.a t(String str, String str2) {
        this.a.x(c.b(str, str2));
        return this;
    }

    @Override
    public m u() throws IOException {
        this.a.l(a.c.POST);
        execute();
        f.n(this.b);
        return this.b.B();
    }

    @Override
    public org.jsoup.a v(String str) {
        f.p(str, TTDownloadField.TT_USERAGENT);
        this.a.k("User-Agent", str);
        return this;
    }

    @Override
    public org.jsoup.a w(a.d dVar) {
        this.a = (d) dVar;
        return this;
    }

    @Override
    public org.jsoup.a x(String str) {
        f.m(str, "url");
        try {
            this.a.j(new URL(Q(str)));
            return this;
        } catch (MalformedURLException e2) {
            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), e2);
        }
    }

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

    @Override
    public org.jsoup.a z(CookieStore cookieStore) {
        this.a.r = new CookieManager(cookieStore, null);
        return this;
    }

    public static abstract class b<T extends a.InterfaceC1080a<T>> implements a.InterfaceC1080a<T> {
        private static final URL f16395e;
        URL a;
        a.c b;
        Map<String, List<String>> c;
        Map<String, String> f16396d;

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

        private static String T(String str) {
            byte[] bytes = str.getBytes(e.l);
            return !V(bytes) ? str : new String(bytes, e.k);
        }

        private List<String> U(String str) {
            f.n(str);
            for (Map.Entry<String, List<String>> entry : this.c.entrySet()) {
                if (str.equalsIgnoreCase(entry.getKey())) {
                    return entry.getValue();
                }
            }
            return Collections.emptyList();
        }

        private static boolean V(byte[] bArr) {
            int i2;
            int i3 = 3;
            i3 = (bArr.length >= 3 && (bArr[0] & 255) == 239 && (bArr[1] & 255) == 187 && (bArr[2] & 255) == 191) ? 0 : 0;
            int length = bArr.length;
            while (i3 < length) {
                byte b = bArr[i3];
                if ((b & 128) != 0) {
                    if ((b & 224) == 192) {
                        i2 = i3 + 1;
                    } else if ((b & 240) == 224) {
                        i2 = i3 + 2;
                    } else if ((b & 248) != 240) {
                        return false;
                    } else {
                        i2 = i3 + 3;
                    }
                    if (i2 >= bArr.length) {
                        return false;
                    }
                    while (i3 < i2) {
                        i3++;
                        if ((bArr[i3] & 192) != 128) {
                            return false;
                        }
                    }
                    continue;
                }
                i3++;
            }
            return true;
        }

        @Nullable
        private Map.Entry<String, List<String>> W(String str) {
            String a = org.jsoup.c.d.a(str);
            for (Map.Entry<String, List<String>> entry : this.c.entrySet()) {
                if (org.jsoup.c.d.a(entry.getKey()).equals(a)) {
                    return entry;
                }
            }
            return null;
        }

        @Override
        public boolean C(String str) {
            f.m(str, "name");
            return this.f16396d.containsKey(str);
        }

        @Override
        public T D(String str) {
            f.m(str, "name");
            Map.Entry<String, List<String>> W = W(str);
            if (W != null) {
                this.c.remove(W.getKey());
            }
            return this;
        }

        @Override
        public String E(String str) {
            f.p(str, "name");
            List<String> U = U(str);
            if (U.size() > 0) {
                return org.jsoup.c.f.k(U, ", ");
            }
            return null;
        }

        @Override
        public boolean F(String str) {
            f.m(str, "name");
            return !U(str).isEmpty();
        }

        @Override
        public T I(String str) {
            f.m(str, "name");
            this.f16396d.remove(str);
            return this;
        }

        @Override
        public List<String> K(String str) {
            f.m(str, "name");
            return U(str);
        }

        @Override
        public Map<String, List<String>> L() {
            return this.c;
        }

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

        @Override
        public T addHeader(String str, String str2) {
            f.m(str, "name");
            if (str2 == null) {
                str2 = "";
            }
            List<String> K = K(str);
            if (K.isEmpty()) {
                K = new ArrayList<>();
                this.c.put(str, K);
            }
            K.add(T(str2));
            return this;
        }

        @Override
        public T c(String str, String str2) {
            f.m(str, "name");
            f.p(str2, com.ubixnow.utils.monitor.data.adapter.c.w);
            this.f16396d.put(str, str2);
            return this;
        }

        @Override
        public T j(URL url) {
            f.p(url, "url");
            this.a = e.T(url);
            return this;
        }

        @Override
        public T k(String str, String str2) {
            f.m(str, "name");
            D(str);
            addHeader(str, str2);
            return this;
        }

        @Override
        public T l(a.c cVar) {
            f.p(cVar, com.gaoding.analytics.android.sdk.c.P);
            this.b = cVar;
            return this;
        }

        @Override
        public a.c method() {
            return this.b;
        }

        @Override
        public boolean t(String str, String str2) {
            f.k(str);
            f.k(str2);
            for (String str3 : K(str)) {
                if (str2.equalsIgnoreCase(str3)) {
                    return true;
                }
            }
            return false;
        }

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

        @Override
        public Map<String, String> y() {
            return this.f16396d;
        }

        @Override
        public String z(String str) {
            f.m(str, "name");
            return this.f16396d.get(str);
        }

        private b() {
            this.a = f16395e;
            this.b = a.c.GET;
            this.c = new LinkedHashMap();
            this.f16396d = new LinkedHashMap();
        }

        private b(b<T> bVar) {
            this.a = f16395e;
            this.b = a.c.GET;
            this.a = bVar.a;
            this.b = bVar.b;
            this.c = new LinkedHashMap();
            for (Map.Entry<String, List<String>> entry : bVar.c.entrySet()) {
                this.c.put(entry.getKey(), new ArrayList(entry.getValue()));
            }
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            this.f16396d = linkedHashMap;
            linkedHashMap.putAll(bVar.f16396d);
        }
    }

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

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

    private e(d dVar, C1088e c1088e) {
        this.a = dVar;
        this.b = c1088e;
    }

    public static class C1088e extends b<a.e> implements a.e {
        private static final int q = 20;
        private static final String r = "Location";
        private static final Pattern s = Pattern.compile("(application|text)/\\w*\\+?xml.*");
        private final int f16402f;
        private final String f16403g;
        @Nullable
        private ByteBuffer f16404h;
        @Nullable
        private InputStream f16405i;
        @Nullable
        private HttpURLConnection j;
        @Nullable
        private String k;
        @Nullable
        private final String l;
        private boolean m;
        private boolean n;
        private int o;
        private final d p;

        C1088e() {
            super();
            this.m = false;
            this.n = false;
            this.o = 0;
            this.f16402f = 400;
            this.f16403g = "Request not made";
            this.p = new d();
            this.l = null;
        }

        private static HttpURLConnection Y(d dVar) throws IOException {
            URLConnection openConnection;
            Proxy v = dVar.v();
            if (v == null) {
                openConnection = dVar.url().openConnection();
            } else {
                openConnection = dVar.url().openConnection(v);
            }
            HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
            httpURLConnection.setRequestMethod(dVar.method().name());
            httpURLConnection.setInstanceFollowRedirects(false);
            httpURLConnection.setConnectTimeout(dVar.timeout());
            httpURLConnection.setReadTimeout(dVar.timeout() / 2);
            if (dVar.u() != null && (httpURLConnection instanceof HttpsURLConnection)) {
                ((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(dVar.u());
            }
            if (dVar.method().b()) {
                httpURLConnection.setDoOutput(true);
            }
            org.jsoup.helper.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;
        }

        private static LinkedHashMap<String, List<String>> Z(HttpURLConnection httpURLConnection) {
            LinkedHashMap<String, List<String>> linkedHashMap = new LinkedHashMap<>();
            int i2 = 0;
            while (true) {
                String headerFieldKey = httpURLConnection.getHeaderFieldKey(i2);
                String headerField = httpURLConnection.getHeaderField(i2);
                if (headerFieldKey == null && headerField == null) {
                    return linkedHashMap;
                }
                i2++;
                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);
                    }
                }
            }
        }

        static C1088e a0(d dVar) throws IOException {
            return b0(dVar, null);
        }

        static C1088e b0(d dVar, @Nullable C1088e c1088e) throws IOException {
            String g0;
            HttpURLConnection Y;
            int responseCode;
            C1088e c1088e2;
            synchronized (dVar) {
                f.f(dVar.s, "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.s = true;
            }
            f.p(dVar, HiAnalyticsConstant.Direction.REQUEST);
            URL url = dVar.url();
            f.o(url, "URL must be specified to connect");
            String protocol = url.getProtocol();
            if (!protocol.equals("http") && !protocol.equals("https")) {
                throw new MalformedURLException("Only http & https protocols supported");
            }
            boolean b = dVar.method().b();
            boolean z = dVar.O() != null;
            if (!b) {
                f.f(z, "Cannot set a request body for HTTP method " + dVar.method());
            }
            C1088e c1088e3 = null;
            try {
                try {
                    if (dVar.w().size() > 0 && (!b || z)) {
                        f0(dVar);
                    } else if (b) {
                        g0 = g0(dVar);
                        long nanoTime = System.nanoTime();
                        Y = Y(dVar);
                        Y.connect();
                        if (Y.getDoOutput()) {
                            OutputStream outputStream = Y.getOutputStream();
                            try {
                                try {
                                    h0(dVar, outputStream, g0);
                                } catch (IOException e2) {
                                    Y.disconnect();
                                    throw e2;
                                }
                            } finally {
                                outputStream.close();
                            }
                        }
                        responseCode = Y.getResponseCode();
                        c1088e2 = new C1088e(Y, dVar, c1088e);
                        if (!c1088e2.F("Location") && dVar.A()) {
                            if (responseCode != 307) {
                                dVar.l(a.c.GET);
                                dVar.w().clear();
                                dVar.b(null);
                                dVar.D("Content-Type");
                            }
                            String E = c1088e2.E("Location");
                            f.n(E);
                            if (E.startsWith("http:/") && E.charAt(6) != '/') {
                                E = E.substring(6);
                            }
                            dVar.j(e.R(org.jsoup.c.f.s(dVar.url(), E)));
                            dVar.s = false;
                            return b0(dVar, c1088e2);
                        } else if ((responseCode < 200 && responseCode < 400) || dVar.q()) {
                            String e3 = c1088e2.e();
                            if (e3 != null && !dVar.H() && !e3.startsWith("text/") && !s.matcher(e3).matches()) {
                                throw new UnsupportedMimeTypeException("Unhandled content type. Must be text/*, application/xml, or application/*+xml", e3, dVar.url().toString());
                            }
                            c1088e2.k = org.jsoup.helper.d.d(c1088e2.l);
                            if (Y.getContentLength() != 0 && dVar.method() != a.c.HEAD) {
                                InputStream errorStream = Y.getErrorStream() != null ? Y.getErrorStream() : Y.getInputStream();
                                c1088e2.f16405i = errorStream;
                                f.n(errorStream);
                                if (c1088e2.t("Content-Encoding", Constants.CP_GZIP)) {
                                    c1088e2.f16405i = new GZIPInputStream(c1088e2.f16405i);
                                } else if (c1088e2.t("Content-Encoding", "deflate")) {
                                    c1088e2.f16405i = new InflaterInputStream(c1088e2.f16405i, new Inflater(true));
                                }
                                c1088e2.f16405i = org.jsoup.c.a.l(c1088e2.f16405i, 32768, dVar.P()).k(nanoTime, dVar.timeout());
                            } else {
                                c1088e2.f16404h = org.jsoup.helper.d.c();
                            }
                            dVar.s = false;
                            c1088e2.m = true;
                            return c1088e2;
                        } else {
                            throw new HttpStatusException("HTTP error fetching URL", responseCode, dVar.url().toString());
                        }
                    }
                    if (!c1088e2.F("Location")) {
                    }
                    if (responseCode < 200) {
                    }
                    throw new HttpStatusException("HTTP error fetching URL", responseCode, dVar.url().toString());
                } catch (IOException e4) {
                    e = e4;
                    c1088e3 = c1088e2;
                    if (c1088e3 != null) {
                        c1088e3.e0();
                    }
                    throw e;
                }
                Y.connect();
                if (Y.getDoOutput()) {
                }
                responseCode = Y.getResponseCode();
                c1088e2 = new C1088e(Y, dVar, c1088e);
            } finally {
                dVar.s = false;
            }
            g0 = null;
            long nanoTime2 = System.nanoTime();
            Y = Y(dVar);
        }

        private void c0() {
            f.h(this.m, "Request must be executed (with .execute(), .get(), or .post() before getting response body");
            if (this.f16405i == null || this.f16404h != null) {
                return;
            }
            f.f(this.n, "Request has already been read (with .parse())");
            try {
                try {
                    this.f16404h = org.jsoup.helper.d.k(this.f16405i, this.p.P());
                } catch (IOException e2) {
                    throw new UncheckedIOException(e2);
                }
            } finally {
                this.n = true;
                e0();
            }
        }

        private void e0() {
            InputStream inputStream = this.f16405i;
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException unused) {
                } catch (Throwable th) {
                    this.f16405i = null;
                    throw th;
                }
                this.f16405i = null;
            }
            HttpURLConnection httpURLConnection = this.j;
            if (httpURLConnection != null) {
                httpURLConnection.disconnect();
                this.j = null;
            }
        }

        private static void f0(a.d dVar) throws IOException {
            boolean z;
            URL url = dVar.url();
            StringBuilder b = org.jsoup.c.f.b();
            b.append(url.getProtocol());
            b.append("://");
            b.append(url.getAuthority());
            b.append(url.getPath());
            b.append("?");
            if (url.getQuery() != null) {
                b.append(url.getQuery());
                z = false;
            } else {
                z = true;
            }
            for (a.b bVar : dVar.w()) {
                f.f(bVar.j(), "InputStream data not supported in URL query string.");
                if (z) {
                    z = false;
                } else {
                    b.append(h0.c);
                }
                b.append(URLEncoder.encode(bVar.a(), org.jsoup.helper.d.c));
                b.append('=');
                b.append(URLEncoder.encode(bVar.value(), org.jsoup.helper.d.c));
            }
            dVar.j(new URL(org.jsoup.c.f.q(b)));
            dVar.w().clear();
        }

        @Nullable
        private static String g0(a.d dVar) {
            String E = dVar.E("Content-Type");
            if (E == null) {
                if (e.S(dVar)) {
                    String i2 = org.jsoup.helper.d.i();
                    dVar.k("Content-Type", "multipart/form-data; boundary=" + i2);
                    return i2;
                }
                dVar.k("Content-Type", "application/x-www-form-urlencoded; charset=" + dVar.r());
            } else if (E.contains(e.f16392g) && !E.contains("boundary")) {
                String i3 = org.jsoup.helper.d.i();
                dVar.k("Content-Type", "multipart/form-data; boundary=" + i3);
                return i3;
            }
            return null;
        }

        private static void h0(a.d dVar, OutputStream outputStream, @Nullable String str) throws IOException {
            Collection<a.b> w = dVar.w();
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, Charset.forName(dVar.r())));
            if (str != null) {
                for (a.b bVar : w) {
                    bufferedWriter.write(HelpFormatter.DEFAULT_LONG_OPT_PREFIX);
                    bufferedWriter.write(str);
                    bufferedWriter.write("\r\n");
                    bufferedWriter.write("Content-Disposition: form-data; name=\"");
                    bufferedWriter.write(e.P(bVar.a()));
                    bufferedWriter.write("\"");
                    InputStream inputStream = bVar.inputStream();
                    if (inputStream != null) {
                        bufferedWriter.write("; filename=\"");
                        bufferedWriter.write(e.P(bVar.value()));
                        bufferedWriter.write("\"\r\nContent-Type: ");
                        String e2 = bVar.e();
                        if (e2 == null) {
                            e2 = "application/octet-stream";
                        }
                        bufferedWriter.write(e2);
                        bufferedWriter.write(com.sigmob.sdk.base.network.b.c);
                        bufferedWriter.flush();
                        org.jsoup.helper.d.a(inputStream, outputStream);
                        outputStream.flush();
                    } else {
                        bufferedWriter.write(com.sigmob.sdk.base.network.b.c);
                        bufferedWriter.write(bVar.value());
                    }
                    bufferedWriter.write("\r\n");
                }
                bufferedWriter.write(HelpFormatter.DEFAULT_LONG_OPT_PREFIX);
                bufferedWriter.write(str);
                bufferedWriter.write(HelpFormatter.DEFAULT_LONG_OPT_PREFIX);
            } else {
                String O = dVar.O();
                if (O != null) {
                    bufferedWriter.write(O);
                } else {
                    boolean z = true;
                    for (a.b bVar2 : w) {
                        if (z) {
                            z = false;
                        } else {
                            bufferedWriter.append(h0.c);
                        }
                        bufferedWriter.write(URLEncoder.encode(bVar2.a(), dVar.r()));
                        bufferedWriter.write(61);
                        bufferedWriter.write(URLEncoder.encode(bVar2.value(), dVar.r()));
                    }
                }
            }
            bufferedWriter.close();
        }

        @Override
        public m B() throws IOException {
            f.h(this.m, "Request must be executed (with .execute(), .get(), or .post() before parsing response");
            if (this.f16404h != null) {
                this.f16405i = new ByteArrayInputStream(this.f16404h.array());
                this.n = false;
            }
            f.f(this.n, "Input stream already read and parsed, cannot re-read.");
            m j = org.jsoup.helper.d.j(this.f16405i, this.k, this.a.toExternalForm(), this.p.S());
            j.X2(new e(this.p, this));
            this.k = j.k3().a().name();
            this.n = true;
            e0();
            return j;
        }

        @Override
        public boolean C(String str) {
            return super.C(str);
        }

        @Override
        public a.e D(String str) {
            return super.D(str);
        }

        @Override
        public String E(String str) {
            return super.E(str);
        }

        @Override
        public boolean F(String str) {
            return super.F(str);
        }

        @Override
        public String G() {
            return this.k;
        }

        @Override
        public a.e I(String str) {
            return super.I(str);
        }

        @Override
        public List K(String str) {
            return super.K(str);
        }

        @Override
        public Map L() {
            return super.L();
        }

        @Override
        public a.e M() {
            c0();
            return this;
        }

        @Override
        public Map N() {
            return super.N();
        }

        @Override
        public String Q() {
            return this.f16403g;
        }

        @Override
        public byte[] R() {
            c0();
            f.n(this.f16404h);
            return this.f16404h.array();
        }

        @Override
        public C1088e J(String str) {
            this.k = str;
            return this;
        }

        @Override
        public a.e addHeader(String str, String str2) {
            return super.addHeader(str, str2);
        }

        @Override
        public String body() {
            c0();
            f.n(this.f16404h);
            String str = this.k;
            String charBuffer = (str == null ? org.jsoup.helper.d.b : Charset.forName(str)).decode(this.f16404h).toString();
            this.f16404h.rewind();
            return charBuffer;
        }

        @Override
        public a.e c(String str, String str2) {
            return super.c(str, str2);
        }

        void d0(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(e.e.b.h.d.D0)) {
                        for (String str : value) {
                            if (str != null) {
                                j jVar = new j(str);
                                String trim = jVar.d(ContainerUtils.KEY_VALUE_DELIMITER).trim();
                                String trim2 = jVar.k(";").trim();
                                if (trim.length() > 0 && !this.f16396d.containsKey(trim)) {
                                    c(trim, trim2);
                                }
                            }
                        }
                    }
                    for (String str2 : value) {
                        addHeader(key, str2);
                    }
                }
            }
        }

        @Override
        public String e() {
            return this.l;
        }

        @Override
        public a.e j(URL url) {
            return super.j(url);
        }

        @Override
        public a.e k(String str, String str2) {
            return super.k(str, str2);
        }

        @Override
        public a.e l(a.c cVar) {
            return super.l(cVar);
        }

        @Override
        public a.c method() {
            return super.method();
        }

        @Override
        public BufferedInputStream s() {
            f.h(this.m, "Request must be executed (with .execute(), .get(), or .post() before getting response body");
            f.f(this.n, "Request has already been read");
            this.n = true;
            return org.jsoup.c.a.l(this.f16405i, 32768, this.p.P());
        }

        @Override
        public int statusCode() {
            return this.f16402f;
        }

        @Override
        public boolean t(String str, String str2) {
            return super.t(str, str2);
        }

        @Override
        public URL url() {
            return super.url();
        }

        @Override
        public Map y() {
            return super.y();
        }

        @Override
        public String z(String str) {
            return super.z(str);
        }

        private C1088e(HttpURLConnection httpURLConnection, d dVar, @Nullable C1088e c1088e) throws IOException {
            super();
            this.m = false;
            this.n = false;
            this.o = 0;
            this.j = httpURLConnection;
            this.p = dVar;
            this.b = a.c.valueOf(httpURLConnection.getRequestMethod());
            this.a = httpURLConnection.getURL();
            this.f16402f = httpURLConnection.getResponseCode();
            this.f16403g = httpURLConnection.getResponseMessage();
            this.l = httpURLConnection.getContentType();
            LinkedHashMap<String, List<String>> Z = Z(httpURLConnection);
            d0(Z);
            org.jsoup.helper.c.d(this.p, this.a, Z);
            if (c1088e != null) {
                for (Map.Entry entry : c1088e.y().entrySet()) {
                    if (!C((String) entry.getKey())) {
                        c((String) entry.getKey(), (String) entry.getValue());
                    }
                }
                c1088e.e0();
                int i2 = c1088e.o + 1;
                this.o = i2;
                if (i2 >= 20) {
                    throw new IOException(String.format("Too many redirects occurred trying to load URL %s", c1088e.url()));
                }
            }
        }
    }

    public static class d extends b<a.d> implements a.d {
        @Nullable
        private Proxy f16398f;
        private int f16399g;
        private int f16400h;
        private boolean f16401i;
        private final Collection<a.b> j;
        @Nullable
        private String k;
        private boolean l;
        private boolean m;
        private org.jsoup.f.g n;
        private boolean o;
        private String p;
        @Nullable
        private SSLSocketFactory q;
        private CookieManager r;
        private volatile boolean s;

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

        d() {
            super();
            this.k = null;
            this.l = false;
            this.m = false;
            this.o = false;
            this.p = org.jsoup.helper.d.c;
            this.s = false;
            this.f16399g = 30000;
            this.f16400h = 2097152;
            this.f16401i = true;
            this.j = new ArrayList();
            this.b = a.c.GET;
            addHeader(e.e.b.h.d.j, Constants.CP_GZIP);
            addHeader("User-Agent", e.f16389d);
            this.n = org.jsoup.f.g.c();
            this.r = new CookieManager();
        }

        @Override
        public boolean A() {
            return this.f16401i;
        }

        @Override
        public boolean C(String str) {
            return super.C(str);
        }

        @Override
        public a.d D(String str) {
            return super.D(str);
        }

        @Override
        public String E(String str) {
            return super.E(str);
        }

        @Override
        public boolean F(String str) {
            return super.F(str);
        }

        @Override
        public boolean H() {
            return this.m;
        }

        @Override
        public a.d I(String str) {
            return super.I(str);
        }

        @Override
        public List K(String str) {
            return super.K(str);
        }

        @Override
        public Map L() {
            return super.L();
        }

        @Override
        public Map N() {
            return super.N();
        }

        @Override
        public String O() {
            return this.k;
        }

        @Override
        public int P() {
            return this.f16400h;
        }

        @Override
        public org.jsoup.f.g S() {
            return this.n;
        }

        @Override
        public a.d a(boolean z) {
            this.f16401i = z;
            return this;
        }

        @Override
        public a.d addHeader(String str, String str2) {
            return super.addHeader(str, str2);
        }

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

        @Override
        public a.d c(String str, String str2) {
            return super.c(str, str2);
        }

        public CookieManager c0() {
            return this.r;
        }

        @Override
        public d x(a.b bVar) {
            f.p(bVar, "keyval");
            this.j.add(bVar);
            return this;
        }

        @Override
        public d i(org.jsoup.f.g gVar) {
            this.n = gVar;
            this.o = true;
            return this;
        }

        @Override
        public void f(SSLSocketFactory sSLSocketFactory) {
            this.q = sSLSocketFactory;
        }

        @Override
        public d m(String str, int i2) {
            this.f16398f = new Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved(str, i2));
            return this;
        }

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

        @Override
        public d h(@Nullable Proxy proxy) {
            this.f16398f = proxy;
            return this;
        }

        @Override
        public d d(int i2) {
            f.h(i2 >= 0, "Timeout milliseconds must be 0 (infinite) or greater");
            this.f16399g = i2;
            return this;
        }

        @Override
        public a.d j(URL url) {
            return super.j(url);
        }

        @Override
        public a.d k(String str, String str2) {
            return super.k(str, str2);
        }

        @Override
        public a.d l(a.c cVar) {
            return super.l(cVar);
        }

        @Override
        public a.c method() {
            return super.method();
        }

        @Override
        public a.d n(int i2) {
            f.h(i2 >= 0, "maxSize must be 0 (unlimited) or larger");
            this.f16400h = i2;
            return this;
        }

        @Override
        public a.d o(boolean z) {
            this.l = z;
            return this;
        }

        @Override
        public a.d p(boolean z) {
            this.m = z;
            return this;
        }

        @Override
        public boolean q() {
            return this.l;
        }

        @Override
        public String r() {
            return this.p;
        }

        @Override
        public boolean t(String str, String str2) {
            return super.t(str, str2);
        }

        @Override
        public int timeout() {
            return this.f16399g;
        }

        @Override
        public SSLSocketFactory u() {
            return this.q;
        }

        @Override
        public URL url() {
            return super.url();
        }

        @Override
        public Proxy v() {
            return this.f16398f;
        }

        @Override
        public Collection<a.b> w() {
            return this.j;
        }

        @Override
        public Map y() {
            return super.y();
        }

        @Override
        public String z(String str) {
            return super.z(str);
        }

        d(d dVar) {
            super(dVar);
            this.k = null;
            this.l = false;
            this.m = false;
            this.o = false;
            this.p = org.jsoup.helper.d.c;
            this.s = false;
            this.f16398f = dVar.f16398f;
            this.p = dVar.p;
            this.f16399g = dVar.f16399g;
            this.f16400h = dVar.f16400h;
            this.f16401i = dVar.f16401i;
            this.j = new ArrayList();
            this.l = dVar.l;
            this.m = dVar.m;
            this.n = dVar.n.g();
            this.o = dVar.o;
            this.q = dVar.q;
            this.r = dVar.r;
            this.s = false;
        }
    }
}