.class public final Lb/a/d/a;
.super Ljava/lang/Object;

# interfaces
.implements Lb/z;


# instance fields
.field private final a:Lb/q;


# direct methods
.method public constructor <init>(Lb/q;)V
    .locals 0

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    iput-object p1, p0, Lb/a/d/a;->a:Lb/q;

    return-void
.end method


# virtual methods
.method public final a(Lb/aa;)Lb/ai;
    .locals 10

    const/4 v2, 0x0

    invoke-interface {p1}, Lb/aa;->a()Lb/af;

    move-result-object v3

    invoke-virtual {v3}, Lb/af;->f()Lb/ag;

    move-result-object v4

    invoke-virtual {v3}, Lb/af;->a()Lb/ah;

    move-result-object v0

    if-eqz v0, :cond_1

    invoke-virtual {v0}, Lb/ah;->b()Lb/ab;

    move-result-object v1

    if-eqz v1, :cond_0

    const-string v5, "Content-Type"

    invoke-virtual {v1}, Lb/ab;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v4, v5, v1}, Lb/ag;->a(Ljava/lang/String;Ljava/lang/String;)Lb/ag;

    :cond_0
    invoke-virtual {v0}, Lb/ah;->a()J

    move-result-wide v0

    const-wide/16 v6, -0x1

    cmp-long v5, v0, v6

    if-eqz v5, :cond_5

    const-string v5, "Content-Length"

    invoke-static {v0, v1}, Ljava/lang/Long;->toString(J)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v4, v5, v0}, Lb/ag;->a(Ljava/lang/String;Ljava/lang/String;)Lb/ag;

    const-string v0, "Transfer-Encoding"

    invoke-virtual {v4, v0}, Lb/ag;->a(Ljava/lang/String;)Lb/ag;

    :cond_1
    :goto_0
    const-string v0, "Host"

    invoke-virtual {v3, v0}, Lb/af;->a(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    if-nez v0, :cond_2

    const-string v0, "Host"

    invoke-virtual {v3}, Lb/af;->g()Lb/w;

    move-result-object v1

    invoke-static {v1, v2}, Lb/a/c;->a(Lb/w;Z)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v4, v0, v1}, Lb/ag;->a(Ljava/lang/String;Ljava/lang/String;)Lb/ag;

    :cond_2
    const-string v0, "Connection"

    invoke-virtual {v3, v0}, Lb/af;->a(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    if-nez v0, :cond_3

    const-string v0, "Connection"

    const-string v1, "Keep-Alive"

    invoke-virtual {v4, v0, v1}, Lb/ag;->a(Ljava/lang/String;Ljava/lang/String;)Lb/ag;

    :cond_3
    const-string v0, "Accept-Encoding"

    invoke-virtual {v3, v0}, Lb/af;->a(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    if-nez v0, :cond_a

    const-string v0, "Accept-Encoding"

    const-string v1, "gzip"

    invoke-virtual {v4, v0, v1}, Lb/ag;->a(Ljava/lang/String;Ljava/lang/String;)Lb/ag;

    const/4 v0, 0x1

    move v1, v0

    :goto_1
    iget-object v0, p0, Lb/a/d/a;->a:Lb/q;

    invoke-virtual {v3}, Lb/af;->g()Lb/w;

    move-result-object v5

    invoke-interface {v0, v5}, Lb/q;->a(Lb/w;)Ljava/util/List;

    move-result-object v5

    invoke-interface {v5}, Ljava/util/List;->isEmpty()Z

    move-result v0

    if-nez v0, :cond_7

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    invoke-interface {v5}, Ljava/util/List;->size()I

    move-result v7

    :goto_2
    if-ge v2, v7, :cond_6

    if-lez v2, :cond_4

    const-string v0, "; "

    invoke-virtual {v6, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    :cond_4
    invoke-interface {v5, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lb/p;

    invoke-virtual {v0}, Lb/p;->a()Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v6, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const/16 v9, 0x3d

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v0}, Lb/p;->b()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v8, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    add-int/lit8 v2, v2, 0x1

    goto :goto_2

    :cond_5
    const-string v0, "Transfer-Encoding"

    const-string v1, "chunked"

    invoke-virtual {v4, v0, v1}, Lb/ag;->a(Ljava/lang/String;Ljava/lang/String;)Lb/ag;

    const-string v0, "Content-Length"

    invoke-virtual {v4, v0}, Lb/ag;->a(Ljava/lang/String;)Lb/ag;

    goto/16 :goto_0

    :cond_6
    const-string v0, "Cookie"

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v4, v0, v2}, Lb/ag;->a(Ljava/lang/String;Ljava/lang/String;)Lb/ag;

    :cond_7
    const-string v0, "User-Agent"

    invoke-virtual {v3, v0}, Lb/af;->a(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    if-nez v0, :cond_8

    const-string v0, "User-Agent"

    invoke-static {}, Lb/a/d;->a()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v4, v0, v2}, Lb/ag;->a(Ljava/lang/String;Ljava/lang/String;)Lb/ag;

    :cond_8
    invoke-virtual {v4}, Lb/ag;->a()Lb/af;

    move-result-object v0

    invoke-interface {p1, v0}, Lb/aa;->a(Lb/af;)Lb/ai;

    move-result-object v0

    iget-object v2, p0, Lb/a/d/a;->a:Lb/q;

    invoke-virtual {v3}, Lb/af;->g()Lb/w;

    move-result-object v4

    invoke-virtual {v0}, Lb/ai;->e()Lb/u;

    move-result-object v5

    invoke-static {v2, v4, v5}, Lb/a/d/m;->a(Lb/q;Lb/w;Lb/u;)V

    invoke-virtual {v0}, Lb/ai;->f()Lb/aj;

    move-result-object v2

    invoke-virtual {v2, v3}, Lb/aj;->a(Lb/af;)Lb/aj;

    move-result-object v2

    if-eqz v1, :cond_9

    const-string v1, "gzip"

    const-string v3, "Content-Encoding"

    invoke-virtual {v0, v3}, Lb/ai;->a(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v3}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_9

    invoke-static {v0}, Lb/a/d/m;->b(Lb/ai;)Z

    move-result v1

    if-eqz v1, :cond_9

    new-instance v1, Lc/j;

    invoke-virtual {v0}, Lb/ai;->a()Lb/ak;

    move-result-object v3

    invoke-virtual {v3}, Lb/ak;->b()Lc/e;

    move-result-object v3

    invoke-direct {v1, v3}, Lc/j;-><init>(Lc/n;)V

    invoke-virtual {v0}, Lb/ai;->e()Lb/u;

    move-result-object v0

    invoke-virtual {v0}, Lb/u;->a()Lb/v;

    move-result-object v0

    const-string v3, "Content-Encoding"

    invoke-virtual {v0, v3}, Lb/v;->b(Ljava/lang/String;)Lb/v;

    move-result-object v0

    const-string v3, "Content-Length"

    invoke-virtual {v0, v3}, Lb/v;->b(Ljava/lang/String;)Lb/v;

    move-result-object v0

    invoke-virtual {v0}, Lb/v;->a()Lb/u;

    move-result-object v0

    invoke-virtual {v2, v0}, Lb/aj;->a(Lb/u;)Lb/aj;

    new-instance v3, Lb/a/d/q;

    invoke-static {v1}, Lc/l;->a(Lc/n;)Lc/e;

    move-result-object v1

    invoke-direct {v3, v0, v1}, Lb/a/d/q;-><init>(Lb/u;Lc/e;)V

    invoke-virtual {v2, v3}, Lb/aj;->a(Lb/ak;)Lb/aj;

    :cond_9
    invoke-virtual {v2}, Lb/aj;->a()Lb/ai;

    move-result-object v0

    return-object v0

    :cond_a
    move v1, v2

    goto/16 :goto_1
.end method
