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 f6089b;

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

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

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

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

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

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

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

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

    @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 f6098a;

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

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

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

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

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

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

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

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

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

        public a() {
            this.f6100c = -1;
            this.f6103f = new r.a();
        }

        public a(d0 d0Var) {
            this.f6100c = -1;
            this.f6098a = d0Var.f6089b;
            this.f6099b = d0Var.f6090c;
            this.f6100c = d0Var.f6091d;
            this.f6101d = d0Var.f6092e;
            this.f6102e = d0Var.f6093f;
            this.f6103f = d0Var.f6094g.e();
            this.f6104g = d0Var.f6095h;
            this.f6105h = d0Var.f6096i;
            this.f6106i = d0Var.f6097j;
            this.f6107j = d0Var.k;
            this.k = d0Var.l;
            this.l = d0Var.m;
        }

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

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

        public final void c(String str, d0 d0Var) {
            if (d0Var.f6095h != null) {
                throw new IllegalArgumentException(a.b.c.a.a.p(str, ".body != null"));
            }
            if (d0Var.f6096i != null) {
                throw new IllegalArgumentException(a.b.c.a.a.p(str, ".networkResponse != null"));
            }
            if (d0Var.f6097j != 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.f6103f = rVar.e();
            return this;
        }
    }

    public d0(a aVar) {
        this.f6089b = aVar.f6098a;
        this.f6090c = aVar.f6099b;
        this.f6091d = aVar.f6100c;
        this.f6092e = aVar.f6101d;
        this.f6093f = aVar.f6102e;
        this.f6094g = new r(aVar.f6103f);
        this.f6095h = aVar.f6104g;
        this.f6096i = aVar.f6105h;
        this.f6097j = aVar.f6106i;
        this.k = aVar.f6107j;
        this.l = aVar.k;
        this.m = aVar.l;
    }

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

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        f0 f0Var = this.f6095h;
        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.f6090c);
        sbC.append(", code=");
        sbC.append(this.f6091d);
        sbC.append(", message=");
        sbC.append(this.f6092e);
        sbC.append(", url=");
        sbC.append(this.f6089b.f6518a);
        sbC.append('}');
        return sbC.toString();
    }
}
