.class public final Lokhttp3/internal/cache/CacheInterceptor; .super Ljava/lang/Object; .source "CacheInterceptor.kt" # interfaces .implements Lokhttp3/Interceptor; # annotations .annotation system Ldalvik/annotation/MemberClasses; value = { Lokhttp3/internal/cache/CacheInterceptor$Companion; } .end annotation .annotation runtime Lkotlin/Metadata; bv = { 0x1, 0x0, 0x3 } d1 = { "\u0000(\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0008\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0008\u0003\n\u0002\u0018\u0002\n\u0002\u0008\u0002\u0018\u0000 \u000f2\u00020\u0001:\u0001\u000fB\u000f\u0012\u0008\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u00a2\u0006\u0002\u0010\u0004J\u001a\u0010\u0007\u001a\u00020\u00082\u0008\u0010\t\u001a\u0004\u0018\u00010\n2\u0006\u0010\u000b\u001a\u00020\u0008H\u0002J\u0010\u0010\u000c\u001a\u00020\u00082\u0006\u0010\r\u001a\u00020\u000eH\u0016R\u0016\u0010\u0002\u001a\u0004\u0018\u00010\u0003X\u0080\u0004\u00a2\u0006\u0008\n\u0000\u001a\u0004\u0008\u0005\u0010\u0006\u00a8\u0006\u0010" } d2 = { "Lokhttp3/internal/cache/CacheInterceptor;", "Lokhttp3/Interceptor;", "cache", "Lokhttp3/Cache;", "(Lokhttp3/Cache;)V", "getCache$okhttp", "()Lokhttp3/Cache;", "cacheWritingResponse", "Lokhttp3/Response;", "cacheRequest", "Lokhttp3/internal/cache/CacheRequest;", "response", "intercept", "chain", "Lokhttp3/Interceptor$Chain;", "Companion", "okhttp" } k = 0x1 mv = { 0x1, 0x4, 0x0 } .end annotation # static fields .field public static final Companion:Lokhttp3/internal/cache/CacheInterceptor$Companion; # instance fields .field private final cache:Lokhttp3/Cache; # direct methods .method static constructor ()V .locals 2 new-instance v0, Lokhttp3/internal/cache/CacheInterceptor$Companion; const/4 v1, 0x0 invoke-direct {v0, v1}, Lokhttp3/internal/cache/CacheInterceptor$Companion;->(Lkotlin/jvm/internal/DefaultConstructorMarker;)V sput-object v0, Lokhttp3/internal/cache/CacheInterceptor;->Companion:Lokhttp3/internal/cache/CacheInterceptor$Companion; return-void .end method .method public constructor (Lokhttp3/Cache;)V .locals 0 .line 42 invoke-direct {p0}, Ljava/lang/Object;->()V iput-object p1, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; return-void .end method .method private final cacheWritingResponse(Lokhttp3/internal/cache/CacheRequest;Lokhttp3/Response;)Lokhttp3/Response; .locals 4 .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/IOException; } .end annotation if-nez p1, :cond_0 return-object p2 .line 166 :cond_0 invoke-interface {p1}, Lokhttp3/internal/cache/CacheRequest;->body()Lokio/Sink; move-result-object p0 .line 168 invoke-virtual {p2}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object v0 invoke-static {v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNull(Ljava/lang/Object;)V invoke-virtual {v0}, Lokhttp3/ResponseBody;->source()Lokio/BufferedSource; move-result-object v0 .line 169 invoke-static {p0}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink; move-result-object p0 .line 171 new-instance v1, Lokhttp3/internal/cache/CacheInterceptor$cacheWritingResponse$cacheWritingSource$1; invoke-direct {v1, v0, p1, p0}, Lokhttp3/internal/cache/CacheInterceptor$cacheWritingResponse$cacheWritingSource$1;->(Lokio/BufferedSource;Lokhttp3/internal/cache/CacheRequest;Lokio/BufferedSink;)V const-string p0, "Content-Type" const/4 p1, 0x2 const/4 v0, 0x0 .line 213 invoke-static {p2, p0, v0, p1, v0}, Lokhttp3/Response;->header$default(Lokhttp3/Response;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String; move-result-object p0 .line 214 invoke-virtual {p2}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object p1 invoke-virtual {p1}, Lokhttp3/ResponseBody;->contentLength()J move-result-wide v2 .line 215 invoke-virtual {p2}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder; move-result-object p1 .line 216 new-instance p2, Lokhttp3/internal/http/RealResponseBody; check-cast v1, Lokio/Source; invoke-static {v1}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource; move-result-object v0 invoke-direct {p2, p0, v2, v3, v0}, Lokhttp3/internal/http/RealResponseBody;->(Ljava/lang/String;JLokio/BufferedSource;)V check-cast p2, Lokhttp3/ResponseBody; invoke-virtual {p1, p2}, Lokhttp3/Response$Builder;->body(Lokhttp3/ResponseBody;)Lokhttp3/Response$Builder; move-result-object p0 .line 217 invoke-virtual {p0}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response; move-result-object p0 return-object p0 .end method # virtual methods .method public final getCache$okhttp()Lokhttp3/Cache; .locals 0 iget-object p0, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; return-object p0 .end method .method public intercept(Lokhttp3/Interceptor$Chain;)Lokhttp3/Response; .locals 8 .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/IOException; } .end annotation const-string v0, "chain" invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V .line 46 invoke-interface {p1}, Lokhttp3/Interceptor$Chain;->call()Lokhttp3/Call; move-result-object v0 iget-object v1, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; const/4 v2, 0x0 if-eqz v1, :cond_0 .line 47 invoke-interface {p1}, Lokhttp3/Interceptor$Chain;->request()Lokhttp3/Request; move-result-object v3 invoke-virtual {v1, v3}, Lokhttp3/Cache;->get$okhttp(Lokhttp3/Request;)Lokhttp3/Response; move-result-object v1 goto :goto_0 :cond_0 move-object v1, v2 .line 49 :goto_0 invoke-static {}, Ljava/lang/System;->currentTimeMillis()J move-result-wide v3 .line 51 new-instance v5, Lokhttp3/internal/cache/CacheStrategy$Factory; invoke-interface {p1}, Lokhttp3/Interceptor$Chain;->request()Lokhttp3/Request; move-result-object v6 invoke-direct {v5, v3, v4, v6, v1}, Lokhttp3/internal/cache/CacheStrategy$Factory;->(JLokhttp3/Request;Lokhttp3/Response;)V invoke-virtual {v5}, Lokhttp3/internal/cache/CacheStrategy$Factory;->compute()Lokhttp3/internal/cache/CacheStrategy; move-result-object v3 .line 52 invoke-virtual {v3}, Lokhttp3/internal/cache/CacheStrategy;->getNetworkRequest()Lokhttp3/Request; move-result-object v4 .line 53 invoke-virtual {v3}, Lokhttp3/internal/cache/CacheStrategy;->getCacheResponse()Lokhttp3/Response; move-result-object v5 iget-object v6, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; if-eqz v6, :cond_1 .line 55 invoke-virtual {v6, v3}, Lokhttp3/Cache;->trackResponse$okhttp(Lokhttp3/internal/cache/CacheStrategy;)V .line 56 :cond_1 instance-of v3, v0, Lokhttp3/internal/connection/RealCall; if-nez v3, :cond_2 move-object v3, v2 goto :goto_1 :cond_2 move-object v3, v0 :goto_1 check-cast v3, Lokhttp3/internal/connection/RealCall; if-eqz v3, :cond_3 invoke-virtual {v3}, Lokhttp3/internal/connection/RealCall;->getEventListener$okhttp()Lokhttp3/EventListener; move-result-object v3 if-eqz v3, :cond_3 goto :goto_2 :cond_3 sget-object v3, Lokhttp3/EventListener;->NONE:Lokhttp3/EventListener; :goto_2 if-eqz v1, :cond_4 if-nez v5, :cond_4 .line 60 invoke-virtual {v1}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object v6 if-eqz v6, :cond_4 check-cast v6, Ljava/io/Closeable; invoke-static {v6}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V :cond_4 if-nez v4, :cond_5 if-nez v5, :cond_5 .line 65 new-instance p0, Lokhttp3/Response$Builder; invoke-direct {p0}, Lokhttp3/Response$Builder;->()V .line 66 invoke-interface {p1}, Lokhttp3/Interceptor$Chain;->request()Lokhttp3/Request; move-result-object p1 invoke-virtual {p0, p1}, Lokhttp3/Response$Builder;->request(Lokhttp3/Request;)Lokhttp3/Response$Builder; move-result-object p0 .line 67 sget-object p1, Lokhttp3/Protocol;->HTTP_1_1:Lokhttp3/Protocol; invoke-virtual {p0, p1}, Lokhttp3/Response$Builder;->protocol(Lokhttp3/Protocol;)Lokhttp3/Response$Builder; move-result-object p0 const/16 p1, 0x1f8 .line 68 invoke-virtual {p0, p1}, Lokhttp3/Response$Builder;->code(I)Lokhttp3/Response$Builder; move-result-object p0 const-string p1, "Unsatisfiable Request (only-if-cached)" .line 69 invoke-virtual {p0, p1}, Lokhttp3/Response$Builder;->message(Ljava/lang/String;)Lokhttp3/Response$Builder; move-result-object p0 .line 70 sget-object p1, Lokhttp3/internal/Util;->EMPTY_RESPONSE:Lokhttp3/ResponseBody; invoke-virtual {p0, p1}, Lokhttp3/Response$Builder;->body(Lokhttp3/ResponseBody;)Lokhttp3/Response$Builder; move-result-object p0 const-wide/16 v1, -0x1 .line 71 invoke-virtual {p0, v1, v2}, Lokhttp3/Response$Builder;->sentRequestAtMillis(J)Lokhttp3/Response$Builder; move-result-object p0 .line 72 invoke-static {}, Ljava/lang/System;->currentTimeMillis()J move-result-wide v1 invoke-virtual {p0, v1, v2}, Lokhttp3/Response$Builder;->receivedResponseAtMillis(J)Lokhttp3/Response$Builder; move-result-object p0 .line 73 invoke-virtual {p0}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response; move-result-object p0 .line 74 invoke-virtual {v3, v0, p0}, Lokhttp3/EventListener;->satisfactionFailure(Lokhttp3/Call;Lokhttp3/Response;)V return-object p0 :cond_5 if-nez v4, :cond_6 .line 80 invoke-static {v5}, Lkotlin/jvm/internal/Intrinsics;->checkNotNull(Ljava/lang/Object;)V invoke-virtual {v5}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder; move-result-object p0 sget-object p1, Lokhttp3/internal/cache/CacheInterceptor;->Companion:Lokhttp3/internal/cache/CacheInterceptor$Companion; .line 81 invoke-static {p1, v5}, Lokhttp3/internal/cache/CacheInterceptor$Companion;->access$stripBody(Lokhttp3/internal/cache/CacheInterceptor$Companion;Lokhttp3/Response;)Lokhttp3/Response; move-result-object p1 invoke-virtual {p0, p1}, Lokhttp3/Response$Builder;->cacheResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder; move-result-object p0 .line 82 invoke-virtual {p0}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response; move-result-object p0 .line 83 invoke-virtual {v3, v0, p0}, Lokhttp3/EventListener;->cacheHit(Lokhttp3/Call;Lokhttp3/Response;)V return-object p0 :cond_6 if-eqz v5, :cond_7 .line 88 invoke-virtual {v3, v0, v5}, Lokhttp3/EventListener;->cacheConditionalHit(Lokhttp3/Call;Lokhttp3/Response;)V goto :goto_3 :cond_7 iget-object v6, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; if-eqz v6, :cond_8 .line 90 invoke-virtual {v3, v0}, Lokhttp3/EventListener;->cacheMiss(Lokhttp3/Call;)V .line 93 :cond_8 :goto_3 check-cast v2, Lokhttp3/Response; .line 95 :try_start_0 invoke-interface {p1, v4}, Lokhttp3/Interceptor$Chain;->proceed(Lokhttp3/Request;)Lokhttp3/Response; move-result-object p1 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 if-nez p1, :cond_9 if-eqz v1, :cond_9 .line 99 invoke-virtual {v1}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object v1 if-eqz v1, :cond_9 check-cast v1, Ljava/io/Closeable; invoke-static {v1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V :cond_9 if-eqz v5, :cond_b if-eqz p1, :cond_a .line 105 invoke-virtual {p1}, Lokhttp3/Response;->code()I move-result v1 const/16 v2, 0x130 if-ne v1, v2, :cond_a .line 106 invoke-virtual {v5}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder; move-result-object v1 sget-object v2, Lokhttp3/internal/cache/CacheInterceptor;->Companion:Lokhttp3/internal/cache/CacheInterceptor$Companion; .line 107 invoke-virtual {v5}, Lokhttp3/Response;->headers()Lokhttp3/Headers; move-result-object v4 invoke-virtual {p1}, Lokhttp3/Response;->headers()Lokhttp3/Headers; move-result-object v6 invoke-static {v2, v4, v6}, Lokhttp3/internal/cache/CacheInterceptor$Companion;->access$combine(Lokhttp3/internal/cache/CacheInterceptor$Companion;Lokhttp3/Headers;Lokhttp3/Headers;)Lokhttp3/Headers; move-result-object v4 invoke-virtual {v1, v4}, Lokhttp3/Response$Builder;->headers(Lokhttp3/Headers;)Lokhttp3/Response$Builder; move-result-object v1 .line 108 invoke-virtual {p1}, Lokhttp3/Response;->sentRequestAtMillis()J move-result-wide v6 invoke-virtual {v1, v6, v7}, Lokhttp3/Response$Builder;->sentRequestAtMillis(J)Lokhttp3/Response$Builder; move-result-object v1 .line 109 invoke-virtual {p1}, Lokhttp3/Response;->receivedResponseAtMillis()J move-result-wide v6 invoke-virtual {v1, v6, v7}, Lokhttp3/Response$Builder;->receivedResponseAtMillis(J)Lokhttp3/Response$Builder; move-result-object v1 .line 110 invoke-static {v2, v5}, Lokhttp3/internal/cache/CacheInterceptor$Companion;->access$stripBody(Lokhttp3/internal/cache/CacheInterceptor$Companion;Lokhttp3/Response;)Lokhttp3/Response; move-result-object v4 invoke-virtual {v1, v4}, Lokhttp3/Response$Builder;->cacheResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder; move-result-object v1 .line 111 invoke-static {v2, p1}, Lokhttp3/internal/cache/CacheInterceptor$Companion;->access$stripBody(Lokhttp3/internal/cache/CacheInterceptor$Companion;Lokhttp3/Response;)Lokhttp3/Response; move-result-object v2 invoke-virtual {v1, v2}, Lokhttp3/Response$Builder;->networkResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder; move-result-object v1 .line 112 invoke-virtual {v1}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response; move-result-object v1 .line 114 invoke-virtual {p1}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object p1 invoke-static {p1}, Lkotlin/jvm/internal/Intrinsics;->checkNotNull(Ljava/lang/Object;)V invoke-virtual {p1}, Lokhttp3/ResponseBody;->close()V iget-object p1, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; .line 118 invoke-static {p1}, Lkotlin/jvm/internal/Intrinsics;->checkNotNull(Ljava/lang/Object;)V invoke-virtual {p1}, Lokhttp3/Cache;->trackConditionalCacheHit$okhttp()V iget-object p0, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; .line 119 invoke-virtual {p0, v5, v1}, Lokhttp3/Cache;->update$okhttp(Lokhttp3/Response;Lokhttp3/Response;)V .line 121 invoke-virtual {v3, v0, v1}, Lokhttp3/EventListener;->cacheHit(Lokhttp3/Call;Lokhttp3/Response;)V return-object v1 .line 124 :cond_a invoke-virtual {v5}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object v1 if-eqz v1, :cond_b check-cast v1, Ljava/io/Closeable; invoke-static {v1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V .line 128 :cond_b invoke-static {p1}, Lkotlin/jvm/internal/Intrinsics;->checkNotNull(Ljava/lang/Object;)V invoke-virtual {p1}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder; move-result-object v1 sget-object v2, Lokhttp3/internal/cache/CacheInterceptor;->Companion:Lokhttp3/internal/cache/CacheInterceptor$Companion; .line 129 invoke-static {v2, v5}, Lokhttp3/internal/cache/CacheInterceptor$Companion;->access$stripBody(Lokhttp3/internal/cache/CacheInterceptor$Companion;Lokhttp3/Response;)Lokhttp3/Response; move-result-object v6 invoke-virtual {v1, v6}, Lokhttp3/Response$Builder;->cacheResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder; move-result-object v1 .line 130 invoke-static {v2, p1}, Lokhttp3/internal/cache/CacheInterceptor$Companion;->access$stripBody(Lokhttp3/internal/cache/CacheInterceptor$Companion;Lokhttp3/Response;)Lokhttp3/Response; move-result-object p1 invoke-virtual {v1, p1}, Lokhttp3/Response$Builder;->networkResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder; move-result-object p1 .line 131 invoke-virtual {p1}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response; move-result-object p1 iget-object v1, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; if-eqz v1, :cond_e .line 134 invoke-static {p1}, Lokhttp3/internal/http/HttpHeaders;->promisesBody(Lokhttp3/Response;)Z move-result v1 if-eqz v1, :cond_d sget-object v1, Lokhttp3/internal/cache/CacheStrategy;->Companion:Lokhttp3/internal/cache/CacheStrategy$Companion; invoke-virtual {v1, p1, v4}, Lokhttp3/internal/cache/CacheStrategy$Companion;->isCacheable(Lokhttp3/Response;Lokhttp3/Request;)Z move-result v1 if-eqz v1, :cond_d iget-object v1, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; .line 136 invoke-virtual {v1, p1}, Lokhttp3/Cache;->put$okhttp(Lokhttp3/Response;)Lokhttp3/internal/cache/CacheRequest; move-result-object v1 .line 137 invoke-direct {p0, v1, p1}, Lokhttp3/internal/cache/CacheInterceptor;->cacheWritingResponse(Lokhttp3/internal/cache/CacheRequest;Lokhttp3/Response;)Lokhttp3/Response; move-result-object p0 if-eqz v5, :cond_c .line 140 invoke-virtual {v3, v0}, Lokhttp3/EventListener;->cacheMiss(Lokhttp3/Call;)V :cond_c return-object p0 .line 145 :cond_d sget-object v0, Lokhttp3/internal/http/HttpMethod;->INSTANCE:Lokhttp3/internal/http/HttpMethod; invoke-virtual {v4}, Lokhttp3/Request;->method()Ljava/lang/String; move-result-object v1 invoke-virtual {v0, v1}, Lokhttp3/internal/http/HttpMethod;->invalidatesCache(Ljava/lang/String;)Z move-result v0 if-eqz v0, :cond_e :try_start_1 iget-object p0, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/Cache; .line 147 invoke-virtual {p0, v4}, Lokhttp3/Cache;->remove$okhttp(Lokhttp3/Request;)V :try_end_1 .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0 :catch_0 :cond_e return-object p1 :catchall_0 move-exception p0 if-eqz v1, :cond_f .line 99 invoke-virtual {v1}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody; move-result-object p1 if-eqz p1, :cond_f check-cast p1, Ljava/io/Closeable; invoke-static {p1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V :cond_f throw p0 .end method