123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668 |
- .class public final Lokhttp3/internal/cache/CacheInterceptor;
- .super Ljava/lang/Object;
- .source ""
- # interfaces
- .implements Lokhttp3/Interceptor;
- # instance fields
- .field final cache:Lokhttp3/internal/cache/InternalCache;
- # direct methods
- .method public constructor <init>(Lokhttp3/internal/cache/InternalCache;)V
- .locals 0
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- iput-object p1, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/internal/cache/InternalCache;
- return-void
- .end method
- .method private 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
- :cond_0
- invoke-interface {p1}, Lokhttp3/internal/cache/CacheRequest;->body()Lokio/Sink;
- move-result-object v0
- if-nez v0, :cond_1
- return-object p2
- :cond_1
- invoke-virtual {p2}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody;
- move-result-object v1
- invoke-virtual {v1}, Lokhttp3/ResponseBody;->source()Lokio/BufferedSource;
- move-result-object v1
- invoke-static {v0}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink;
- move-result-object v0
- new-instance v2, Lokhttp3/internal/cache/CacheInterceptor$1;
- invoke-direct {v2, p0, v1, p1, v0}, Lokhttp3/internal/cache/CacheInterceptor$1;-><init>(Lokhttp3/internal/cache/CacheInterceptor;Lokio/BufferedSource;Lokhttp3/internal/cache/CacheRequest;Lokio/BufferedSink;)V
- const-string p1, "Content-Type"
- invoke-virtual {p2, p1}, Lokhttp3/Response;->header(Ljava/lang/String;)Ljava/lang/String;
- move-result-object p1
- invoke-virtual {p2}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody;
- move-result-object v0
- invoke-virtual {v0}, Lokhttp3/ResponseBody;->contentLength()J
- move-result-wide v0
- invoke-virtual {p2}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder;
- move-result-object p2
- new-instance v3, Lokhttp3/internal/http/RealResponseBody;
- invoke-static {v2}, Lokio/Okio;->buffer(Lokio/Source;)Lokio/BufferedSource;
- move-result-object v2
- invoke-direct {v3, p1, v0, v1, v2}, Lokhttp3/internal/http/RealResponseBody;-><init>(Ljava/lang/String;JLokio/BufferedSource;)V
- invoke-virtual {p2, v3}, Lokhttp3/Response$Builder;->body(Lokhttp3/ResponseBody;)Lokhttp3/Response$Builder;
- move-result-object p1
- invoke-virtual {p1}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response;
- move-result-object p1
- return-object p1
- .end method
- .method private static combine(Lokhttp3/Headers;Lokhttp3/Headers;)Lokhttp3/Headers;
- .locals 7
- new-instance v0, Lokhttp3/Headers$Builder;
- invoke-direct {v0}, Lokhttp3/Headers$Builder;-><init>()V
- invoke-virtual {p0}, Lokhttp3/Headers;->size()I
- move-result v1
- const/4 v2, 0x0
- const/4 v3, 0x0
- :goto_0
- if-ge v3, v1, :cond_3
- invoke-virtual {p0, v3}, Lokhttp3/Headers;->name(I)Ljava/lang/String;
- move-result-object v4
- invoke-virtual {p0, v3}, Lokhttp3/Headers;->value(I)Ljava/lang/String;
- move-result-object v5
- const-string v6, "Warning"
- invoke-virtual {v6, v4}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v6
- if-eqz v6, :cond_0
- const-string v6, "1"
- invoke-virtual {v5, v6}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
- move-result v6
- if-eqz v6, :cond_0
- goto :goto_1
- :cond_0
- invoke-static {v4}, Lokhttp3/internal/cache/CacheInterceptor;->isEndToEnd(Ljava/lang/String;)Z
- move-result v6
- if-eqz v6, :cond_1
- invoke-virtual {p1, v4}, Lokhttp3/Headers;->get(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v6
- if-nez v6, :cond_2
- :cond_1
- sget-object v6, Lokhttp3/internal/Internal;->instance:Lokhttp3/internal/Internal;
- invoke-virtual {v6, v0, v4, v5}, Lokhttp3/internal/Internal;->addLenient(Lokhttp3/Headers$Builder;Ljava/lang/String;Ljava/lang/String;)V
- :cond_2
- :goto_1
- add-int/lit8 v3, v3, 0x1
- goto :goto_0
- :cond_3
- invoke-virtual {p1}, Lokhttp3/Headers;->size()I
- move-result p0
- :goto_2
- if-ge v2, p0, :cond_6
- invoke-virtual {p1, v2}, Lokhttp3/Headers;->name(I)Ljava/lang/String;
- move-result-object v1
- const-string v3, "Content-Length"
- invoke-virtual {v3, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v3
- if-eqz v3, :cond_4
- goto :goto_3
- :cond_4
- invoke-static {v1}, Lokhttp3/internal/cache/CacheInterceptor;->isEndToEnd(Ljava/lang/String;)Z
- move-result v3
- if-eqz v3, :cond_5
- sget-object v3, Lokhttp3/internal/Internal;->instance:Lokhttp3/internal/Internal;
- invoke-virtual {p1, v2}, Lokhttp3/Headers;->value(I)Ljava/lang/String;
- move-result-object v4
- invoke-virtual {v3, v0, v1, v4}, Lokhttp3/internal/Internal;->addLenient(Lokhttp3/Headers$Builder;Ljava/lang/String;Ljava/lang/String;)V
- :cond_5
- :goto_3
- add-int/lit8 v2, v2, 0x1
- goto :goto_2
- :cond_6
- invoke-virtual {v0}, Lokhttp3/Headers$Builder;->build()Lokhttp3/Headers;
- move-result-object p0
- return-object p0
- .end method
- .method static isEndToEnd(Ljava/lang/String;)Z
- .locals 1
- const-string v0, "Connection"
- invoke-virtual {v0, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v0
- if-nez v0, :cond_0
- const-string v0, "Keep-Alive"
- invoke-virtual {v0, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v0
- if-nez v0, :cond_0
- const-string v0, "Proxy-Authenticate"
- invoke-virtual {v0, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v0
- if-nez v0, :cond_0
- const-string v0, "Proxy-Authorization"
- invoke-virtual {v0, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v0
- if-nez v0, :cond_0
- const-string v0, "TE"
- invoke-virtual {v0, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v0
- if-nez v0, :cond_0
- const-string v0, "Trailers"
- invoke-virtual {v0, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v0
- if-nez v0, :cond_0
- const-string v0, "Transfer-Encoding"
- invoke-virtual {v0, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v0
- if-nez v0, :cond_0
- const-string v0, "Upgrade"
- invoke-virtual {v0, p0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result p0
- if-nez p0, :cond_0
- const/4 p0, 0x1
- goto :goto_0
- :cond_0
- const/4 p0, 0x0
- :goto_0
- return p0
- .end method
- .method private static stripBody(Lokhttp3/Response;)Lokhttp3/Response;
- .locals 1
- if-eqz p0, :cond_0
- invoke-virtual {p0}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody;
- move-result-object v0
- if-eqz v0, :cond_0
- invoke-virtual {p0}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder;
- move-result-object p0
- const/4 v0, 0x0
- invoke-virtual {p0, v0}, Lokhttp3/Response$Builder;->body(Lokhttp3/ResponseBody;)Lokhttp3/Response$Builder;
- move-result-object p0
- invoke-virtual {p0}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response;
- move-result-object p0
- :cond_0
- return-object p0
- .end method
- # virtual methods
- .method public intercept(Lokhttp3/Interceptor$Chain;)Lokhttp3/Response;
- .locals 5
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- iget-object v0, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/internal/cache/InternalCache;
- if-eqz v0, :cond_0
- invoke-interface {p1}, Lokhttp3/Interceptor$Chain;->request()Lokhttp3/Request;
- move-result-object v1
- invoke-interface {v0, v1}, Lokhttp3/internal/cache/InternalCache;->get(Lokhttp3/Request;)Lokhttp3/Response;
- move-result-object v0
- goto :goto_0
- :cond_0
- const/4 v0, 0x0
- :goto_0
- invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
- move-result-wide v1
- new-instance v3, Lokhttp3/internal/cache/CacheStrategy$Factory;
- invoke-interface {p1}, Lokhttp3/Interceptor$Chain;->request()Lokhttp3/Request;
- move-result-object v4
- invoke-direct {v3, v1, v2, v4, v0}, Lokhttp3/internal/cache/CacheStrategy$Factory;-><init>(JLokhttp3/Request;Lokhttp3/Response;)V
- invoke-virtual {v3}, Lokhttp3/internal/cache/CacheStrategy$Factory;->get()Lokhttp3/internal/cache/CacheStrategy;
- move-result-object v1
- iget-object v2, v1, Lokhttp3/internal/cache/CacheStrategy;->networkRequest:Lokhttp3/Request;
- iget-object v3, v1, Lokhttp3/internal/cache/CacheStrategy;->cacheResponse:Lokhttp3/Response;
- iget-object v4, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/internal/cache/InternalCache;
- if-eqz v4, :cond_1
- invoke-interface {v4, v1}, Lokhttp3/internal/cache/InternalCache;->trackResponse(Lokhttp3/internal/cache/CacheStrategy;)V
- :cond_1
- if-eqz v0, :cond_2
- if-nez v3, :cond_2
- invoke-virtual {v0}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody;
- move-result-object v1
- invoke-static {v1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- :cond_2
- if-nez v2, :cond_3
- if-nez v3, :cond_3
- new-instance v0, Lokhttp3/Response$Builder;
- invoke-direct {v0}, Lokhttp3/Response$Builder;-><init>()V
- invoke-interface {p1}, Lokhttp3/Interceptor$Chain;->request()Lokhttp3/Request;
- move-result-object p1
- invoke-virtual {v0, p1}, Lokhttp3/Response$Builder;->request(Lokhttp3/Request;)Lokhttp3/Response$Builder;
- move-result-object p1
- sget-object v0, Lokhttp3/Protocol;->HTTP_1_1:Lokhttp3/Protocol;
- invoke-virtual {p1, v0}, Lokhttp3/Response$Builder;->protocol(Lokhttp3/Protocol;)Lokhttp3/Response$Builder;
- move-result-object p1
- const/16 v0, 0x1f8
- invoke-virtual {p1, v0}, Lokhttp3/Response$Builder;->code(I)Lokhttp3/Response$Builder;
- move-result-object p1
- const-string v0, "Unsatisfiable Request (only-if-cached)"
- invoke-virtual {p1, v0}, Lokhttp3/Response$Builder;->message(Ljava/lang/String;)Lokhttp3/Response$Builder;
- move-result-object p1
- sget-object v0, Lokhttp3/internal/Util;->EMPTY_RESPONSE:Lokhttp3/ResponseBody;
- invoke-virtual {p1, v0}, Lokhttp3/Response$Builder;->body(Lokhttp3/ResponseBody;)Lokhttp3/Response$Builder;
- move-result-object p1
- const-wide/16 v0, -0x1
- invoke-virtual {p1, v0, v1}, Lokhttp3/Response$Builder;->sentRequestAtMillis(J)Lokhttp3/Response$Builder;
- move-result-object p1
- invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
- move-result-wide v0
- invoke-virtual {p1, v0, v1}, Lokhttp3/Response$Builder;->receivedResponseAtMillis(J)Lokhttp3/Response$Builder;
- move-result-object p1
- invoke-virtual {p1}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response;
- move-result-object p1
- return-object p1
- :cond_3
- if-nez v2, :cond_4
- invoke-virtual {v3}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder;
- move-result-object p1
- invoke-static {v3}, Lokhttp3/internal/cache/CacheInterceptor;->stripBody(Lokhttp3/Response;)Lokhttp3/Response;
- move-result-object v0
- invoke-virtual {p1, v0}, Lokhttp3/Response$Builder;->cacheResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder;
- move-result-object p1
- invoke-virtual {p1}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response;
- move-result-object p1
- return-object p1
- :cond_4
- :try_start_0
- invoke-interface {p1, v2}, 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_5
- if-eqz v0, :cond_5
- invoke-virtual {v0}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody;
- move-result-object v0
- invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- :cond_5
- if-eqz v3, :cond_7
- invoke-virtual {p1}, Lokhttp3/Response;->code()I
- move-result v0
- const/16 v1, 0x130
- if-ne v0, v1, :cond_6
- invoke-virtual {v3}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder;
- move-result-object v0
- invoke-virtual {v3}, Lokhttp3/Response;->headers()Lokhttp3/Headers;
- move-result-object v1
- invoke-virtual {p1}, Lokhttp3/Response;->headers()Lokhttp3/Headers;
- move-result-object v2
- invoke-static {v1, v2}, Lokhttp3/internal/cache/CacheInterceptor;->combine(Lokhttp3/Headers;Lokhttp3/Headers;)Lokhttp3/Headers;
- move-result-object v1
- invoke-virtual {v0, v1}, Lokhttp3/Response$Builder;->headers(Lokhttp3/Headers;)Lokhttp3/Response$Builder;
- move-result-object v0
- invoke-virtual {p1}, Lokhttp3/Response;->sentRequestAtMillis()J
- move-result-wide v1
- invoke-virtual {v0, v1, v2}, Lokhttp3/Response$Builder;->sentRequestAtMillis(J)Lokhttp3/Response$Builder;
- move-result-object v0
- invoke-virtual {p1}, Lokhttp3/Response;->receivedResponseAtMillis()J
- move-result-wide v1
- invoke-virtual {v0, v1, v2}, Lokhttp3/Response$Builder;->receivedResponseAtMillis(J)Lokhttp3/Response$Builder;
- move-result-object v0
- invoke-static {v3}, Lokhttp3/internal/cache/CacheInterceptor;->stripBody(Lokhttp3/Response;)Lokhttp3/Response;
- move-result-object v1
- invoke-virtual {v0, v1}, Lokhttp3/Response$Builder;->cacheResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder;
- move-result-object v0
- invoke-static {p1}, Lokhttp3/internal/cache/CacheInterceptor;->stripBody(Lokhttp3/Response;)Lokhttp3/Response;
- move-result-object v1
- invoke-virtual {v0, v1}, Lokhttp3/Response$Builder;->networkResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder;
- move-result-object v0
- invoke-virtual {v0}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response;
- move-result-object v0
- invoke-virtual {p1}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody;
- move-result-object p1
- invoke-virtual {p1}, Lokhttp3/ResponseBody;->close()V
- iget-object p1, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/internal/cache/InternalCache;
- invoke-interface {p1}, Lokhttp3/internal/cache/InternalCache;->trackConditionalCacheHit()V
- iget-object p1, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/internal/cache/InternalCache;
- invoke-interface {p1, v3, v0}, Lokhttp3/internal/cache/InternalCache;->update(Lokhttp3/Response;Lokhttp3/Response;)V
- return-object v0
- :cond_6
- invoke-virtual {v3}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody;
- move-result-object v0
- invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- :cond_7
- invoke-virtual {p1}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder;
- move-result-object v0
- invoke-static {v3}, Lokhttp3/internal/cache/CacheInterceptor;->stripBody(Lokhttp3/Response;)Lokhttp3/Response;
- move-result-object v1
- invoke-virtual {v0, v1}, Lokhttp3/Response$Builder;->cacheResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder;
- move-result-object v0
- invoke-static {p1}, Lokhttp3/internal/cache/CacheInterceptor;->stripBody(Lokhttp3/Response;)Lokhttp3/Response;
- move-result-object p1
- invoke-virtual {v0, p1}, Lokhttp3/Response$Builder;->networkResponse(Lokhttp3/Response;)Lokhttp3/Response$Builder;
- move-result-object p1
- invoke-virtual {p1}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response;
- move-result-object p1
- iget-object v0, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/internal/cache/InternalCache;
- if-eqz v0, :cond_9
- invoke-static {p1}, Lokhttp3/internal/http/HttpHeaders;->hasBody(Lokhttp3/Response;)Z
- move-result v0
- if-eqz v0, :cond_8
- invoke-static {p1, v2}, Lokhttp3/internal/cache/CacheStrategy;->isCacheable(Lokhttp3/Response;Lokhttp3/Request;)Z
- move-result v0
- if-eqz v0, :cond_8
- iget-object v0, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/internal/cache/InternalCache;
- invoke-interface {v0, p1}, Lokhttp3/internal/cache/InternalCache;->put(Lokhttp3/Response;)Lokhttp3/internal/cache/CacheRequest;
- move-result-object v0
- invoke-direct {p0, v0, p1}, Lokhttp3/internal/cache/CacheInterceptor;->cacheWritingResponse(Lokhttp3/internal/cache/CacheRequest;Lokhttp3/Response;)Lokhttp3/Response;
- move-result-object p1
- return-object p1
- :cond_8
- invoke-virtual {v2}, Lokhttp3/Request;->method()Ljava/lang/String;
- move-result-object v0
- invoke-static {v0}, Lokhttp3/internal/http/HttpMethod;->invalidatesCache(Ljava/lang/String;)Z
- move-result v0
- if-eqz v0, :cond_9
- :try_start_1
- iget-object v0, p0, Lokhttp3/internal/cache/CacheInterceptor;->cache:Lokhttp3/internal/cache/InternalCache;
- invoke-interface {v0, v2}, Lokhttp3/internal/cache/InternalCache;->remove(Lokhttp3/Request;)V
- :try_end_1
- .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
- :catch_0
- :cond_9
- return-object p1
- :catchall_0
- move-exception p1
- if-eqz v0, :cond_a
- invoke-virtual {v0}, Lokhttp3/Response;->body()Lokhttp3/ResponseBody;
- move-result-object v0
- invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- :cond_a
- throw p1
- .end method
|