package g;

import g.r;
import java.io.Closeable;
import javax.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public final class d0 implements Closeable {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final z f6075b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final x f6076c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final int f6077d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final String f6078e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    @Nullable
    public final q f6079f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final r f6080g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    @Nullable
    public final f0 f6081h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    @Nullable
    public final d0 f6082i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    @Nullable
    public final d0 f6083j;

    @Nullable
    public final d0 k;
    public final long l;
    public final long m;

    public static class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        @Nullable
        public z f6084a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        @Nullable
        public x f6085b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f6086c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public String f6087d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        @Nullable
        public q f6088e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public r.a f6089f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        @Nullable
        public f0 f6090g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        @Nullable
        public d0 f6091h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        @Nullable
        public d0 f6092i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        @Nullable
        public d0 f6093j;
        public long k;
        public long l;

        public a() {
            this.f6086c = -1;
            this.f6089f = new r.a();
        }

        public a(d0 d0Var) {
            this.f6086c = -1;
            this.f6084a = d0Var.f6075b;
            this.f6085b = d0Var.f6076c;
            this.f6086c = d0Var.f6077d;
            this.f6087d = d0Var.f6078e;
            this.f6088e = d0Var.f6079f;
            this.f6089f = d0Var.f6080g.e();
            this.f6090g = d0Var.f6081h;
            this.f6091h = d0Var.f6082i;
            this.f6092i = d0Var.f6083j;
            this.f6093j = d0Var.k;
            this.k = d0Var.l;
            this.l = d0Var.m;
        }

        public d0 a() {
            if (this.f6084a == null) {
                throw new IllegalStateException("request == null");
            }
            if (this.f6085b == null) {
                throw new IllegalStateException("protocol == null");
            }
            if (this.f6086c >= 0) {
                if (this.f6087d != null) {
                    return new d0(this);
                }
                throw new IllegalStateException("message == null");
            }
            StringBuilder sbC = a.b.c.a.a.C("code < 0: ");
            sbC.append(this.f6086c);
            throw new IllegalStateException(sbC.toString());
        }

        public a b(@Nullable d0 d0Var) {
            if (d0Var != null) {
                c("cacheResponse", d0Var);
            }
            this.f6092i = d0Var;
            return this;
        }

        public final void c(String str, d0 d0Var) {
            if (d0Var.f6081h != null) {
                throw new IllegalArgumentException(a.b.c.a.a.p(str, ".body != null"));
            }
            if (d0Var.f6082i != null) {
                throw new IllegalArgumentException(a.b.c.a.a.p(str, ".networkResponse != null"));
            }
            if (d0Var.f6083j != null) {
                throw new IllegalArgumentException(a.b.c.a.a.p(str, ".cacheResponse != null"));
            }
            if (d0Var.k != null) {
                throw new IllegalArgumentException(a.b.c.a.a.p(str, ".priorResponse != null"));
            }
        }

        public a d(r rVar) {
            this.f6089f = rVar.e();
            return this;
        }
    }

    public d0(a aVar) {
        this.f6075b = aVar.f6084a;
        this.f6076c = aVar.f6085b;
        this.f6077d = aVar.f6086c;
        this.f6078e = aVar.f6087d;
        this.f6079f = aVar.f6088e;
        this.f6080g = new r(aVar.f6089f);
        this.f6081h = aVar.f6090g;
        this.f6082i = aVar.f6091h;
        this.f6083j = aVar.f6092i;
        this.k = aVar.f6093j;
        this.l = aVar.k;
        this.m = aVar.l;
    }

    public boolean a() {
        int i2 = this.f6077d;
        return i2 >= 200 && i2 < 300;
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        f0 f0Var = this.f6081h;
        if (f0Var == null) {
            throw new IllegalStateException("response is not eligible for a body and must not be closed");
        }
        f0Var.close();
    }

    public String toString() {
        StringBuilder sbC = a.b.c.a.a.C("Response{protocol=");
        sbC.append(this.f6076c);
        sbC.append(", code=");
        sbC.append(this.f6077d);
        sbC.append(", message=");
        sbC.append(this.f6078e);
        sbC.append(", url=");
        sbC.append(this.f6075b.f6504a);
        sbC.append('}');
        return sbC.toString();
    }
}
