package wg;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.UnknownServiceException;

/* loaded from: classes4.dex */
class p implements o {

    /* renamed from: b, reason: collision with root package name */
    private static final String f49407b = "p";

    /* renamed from: a, reason: collision with root package name */
    private final HttpURLConnection f49408a;

    /* JADX INFO: Access modifiers changed from: package-private */
    public p(HttpURLConnection httpURLConnection) {
        this.f49408a = httpURLConnection;
    }

    @Override // wg.o
    public InputStream a() {
        try {
            return this.f49408a.getErrorStream();
        } catch (Error e10) {
            t.f("Services", f49407b, String.format("Could not get the input stream. (%s)", e10), new Object[0]);
            return null;
        } catch (Exception e11) {
            t.f("Services", f49407b, String.format("Could not get the input stream. (%s)", e11), new Object[0]);
            return null;
        }
    }

    @Override // wg.o
    public String b(String str) {
        return this.f49408a.getHeaderField(str);
    }

    @Override // wg.o
    public InputStream c() {
        try {
            return this.f49408a.getInputStream();
        } catch (Error e10) {
            t.f("Services", f49407b, String.format("Could not get the input stream. (%s)", e10), new Object[0]);
            return null;
        } catch (UnknownServiceException e11) {
            t.f("Services", f49407b, String.format("Could not get the input stream, protocol does not support input. (%s)", e11), new Object[0]);
            return null;
        } catch (Exception e12) {
            t.f("Services", f49407b, String.format("Could not get the input stream. (%s)", e12), new Object[0]);
            return null;
        }
    }

    @Override // wg.o
    public void close() {
        InputStream c10 = c();
        InputStream a10 = a();
        if (c10 != null) {
            try {
                c10.close();
            } catch (Error e10) {
                t.f("Services", f49407b, String.format("Could not close the input stream. (%s)", e10), new Object[0]);
            } catch (Exception e11) {
                t.f("Services", f49407b, String.format("Could not close the input stream. (%s)", e11), new Object[0]);
            }
        }
        if (a10 != null) {
            try {
                a10.close();
            } catch (Error | Exception e12) {
                t.f("Services", f49407b, String.format("Could not close the error stream. (%s)", e12), new Object[0]);
            }
        }
        this.f49408a.disconnect();
    }

    @Override // wg.o
    public int d() {
        try {
            return this.f49408a.getResponseCode();
        } catch (Error e10) {
            t.f("Services", f49407b, String.format("Could not get response code. (%s)", e10), new Object[0]);
            return -1;
        } catch (Exception e11) {
            t.f("Services", f49407b, String.format("Could not get response code. (%s)", e11), new Object[0]);
            return -1;
        }
    }
}
