123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- .class public Lokhttp3/mockwebserver/QueueDispatcher;
- .super Lokhttp3/mockwebserver/Dispatcher;
- .source ""
- # static fields
- .field private static final DEAD_LETTER:Lokhttp3/mockwebserver/MockResponse;
- .field private static final logger:Ljava/util/logging/Logger;
- # instance fields
- .field private failFastResponse:Lokhttp3/mockwebserver/MockResponse;
- .field protected final responseQueue:Ljava/util/concurrent/BlockingQueue;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/concurrent/BlockingQueue<",
- "Lokhttp3/mockwebserver/MockResponse;",
- ">;"
- }
- .end annotation
- .end field
- # direct methods
- .method static constructor <clinit>()V
- .locals 2
- new-instance v0, Lokhttp3/mockwebserver/MockResponse;
- invoke-direct {v0}, Lokhttp3/mockwebserver/MockResponse;-><init>()V
- const-string v1, "HTTP/1.1 503 shutting down"
- invoke-virtual {v0, v1}, Lokhttp3/mockwebserver/MockResponse;->setStatus(Ljava/lang/String;)Lokhttp3/mockwebserver/MockResponse;
- move-result-object v0
- sput-object v0, Lokhttp3/mockwebserver/QueueDispatcher;->DEAD_LETTER:Lokhttp3/mockwebserver/MockResponse;
- const-class v0, Lokhttp3/mockwebserver/QueueDispatcher;
- invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;
- move-result-object v0
- invoke-static {v0}, Ljava/util/logging/Logger;->getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;
- move-result-object v0
- sput-object v0, Lokhttp3/mockwebserver/QueueDispatcher;->logger:Ljava/util/logging/Logger;
- return-void
- .end method
- .method public constructor <init>()V
- .locals 1
- invoke-direct {p0}, Lokhttp3/mockwebserver/Dispatcher;-><init>()V
- new-instance v0, Ljava/util/concurrent/LinkedBlockingQueue;
- invoke-direct {v0}, Ljava/util/concurrent/LinkedBlockingQueue;-><init>()V
- iput-object v0, p0, Lokhttp3/mockwebserver/QueueDispatcher;->responseQueue:Ljava/util/concurrent/BlockingQueue;
- return-void
- .end method
- # virtual methods
- .method public dispatch(Lokhttp3/mockwebserver/RecordedRequest;)Lokhttp3/mockwebserver/MockResponse;
- .locals 3
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/lang/InterruptedException;
- }
- .end annotation
- invoke-virtual {p1}, Lokhttp3/mockwebserver/RecordedRequest;->getRequestLine()Ljava/lang/String;
- move-result-object p1
- if-eqz p1, :cond_0
- const-string v0, "GET /favicon.ico HTTP/1.1"
- invoke-virtual {p1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
- move-result v0
- if-eqz v0, :cond_0
- sget-object v0, Lokhttp3/mockwebserver/QueueDispatcher;->logger:Ljava/util/logging/Logger;
- new-instance v1, Ljava/lang/StringBuilder;
- invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
- const-string v2, "served "
- invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p1
- invoke-virtual {v0, p1}, Ljava/util/logging/Logger;->info(Ljava/lang/String;)V
- new-instance p1, Lokhttp3/mockwebserver/MockResponse;
- invoke-direct {p1}, Lokhttp3/mockwebserver/MockResponse;-><init>()V
- const/16 v0, 0x194
- invoke-virtual {p1, v0}, Lokhttp3/mockwebserver/MockResponse;->setResponseCode(I)Lokhttp3/mockwebserver/MockResponse;
- move-result-object p1
- return-object p1
- :cond_0
- iget-object p1, p0, Lokhttp3/mockwebserver/QueueDispatcher;->failFastResponse:Lokhttp3/mockwebserver/MockResponse;
- if-eqz p1, :cond_1
- iget-object p1, p0, Lokhttp3/mockwebserver/QueueDispatcher;->responseQueue:Ljava/util/concurrent/BlockingQueue;
- invoke-interface {p1}, Ljava/util/concurrent/BlockingQueue;->peek()Ljava/lang/Object;
- move-result-object p1
- if-nez p1, :cond_1
- iget-object p1, p0, Lokhttp3/mockwebserver/QueueDispatcher;->failFastResponse:Lokhttp3/mockwebserver/MockResponse;
- return-object p1
- :cond_1
- iget-object p1, p0, Lokhttp3/mockwebserver/QueueDispatcher;->responseQueue:Ljava/util/concurrent/BlockingQueue;
- invoke-interface {p1}, Ljava/util/concurrent/BlockingQueue;->take()Ljava/lang/Object;
- move-result-object p1
- check-cast p1, Lokhttp3/mockwebserver/MockResponse;
- sget-object v0, Lokhttp3/mockwebserver/QueueDispatcher;->DEAD_LETTER:Lokhttp3/mockwebserver/MockResponse;
- if-ne p1, v0, :cond_2
- iget-object v1, p0, Lokhttp3/mockwebserver/QueueDispatcher;->responseQueue:Ljava/util/concurrent/BlockingQueue;
- invoke-interface {v1, v0}, Ljava/util/concurrent/BlockingQueue;->add(Ljava/lang/Object;)Z
- :cond_2
- return-object p1
- .end method
- .method public enqueueResponse(Lokhttp3/mockwebserver/MockResponse;)V
- .locals 1
- iget-object v0, p0, Lokhttp3/mockwebserver/QueueDispatcher;->responseQueue:Ljava/util/concurrent/BlockingQueue;
- invoke-interface {v0, p1}, Ljava/util/concurrent/BlockingQueue;->add(Ljava/lang/Object;)Z
- return-void
- .end method
- .method public peek()Lokhttp3/mockwebserver/MockResponse;
- .locals 1
- iget-object v0, p0, Lokhttp3/mockwebserver/QueueDispatcher;->responseQueue:Ljava/util/concurrent/BlockingQueue;
- invoke-interface {v0}, Ljava/util/concurrent/BlockingQueue;->peek()Ljava/lang/Object;
- move-result-object v0
- check-cast v0, Lokhttp3/mockwebserver/MockResponse;
- if-eqz v0, :cond_0
- return-object v0
- :cond_0
- iget-object v0, p0, Lokhttp3/mockwebserver/QueueDispatcher;->failFastResponse:Lokhttp3/mockwebserver/MockResponse;
- if-eqz v0, :cond_1
- return-object v0
- :cond_1
- invoke-super {p0}, Lokhttp3/mockwebserver/Dispatcher;->peek()Lokhttp3/mockwebserver/MockResponse;
- move-result-object v0
- return-object v0
- .end method
- .method public setFailFast(Lokhttp3/mockwebserver/MockResponse;)V
- .locals 0
- iput-object p1, p0, Lokhttp3/mockwebserver/QueueDispatcher;->failFastResponse:Lokhttp3/mockwebserver/MockResponse;
- return-void
- .end method
- .method public setFailFast(Z)V
- .locals 1
- if-eqz p1, :cond_0
- new-instance p1, Lokhttp3/mockwebserver/MockResponse;
- invoke-direct {p1}, Lokhttp3/mockwebserver/MockResponse;-><init>()V
- const/16 v0, 0x194
- invoke-virtual {p1, v0}, Lokhttp3/mockwebserver/MockResponse;->setResponseCode(I)Lokhttp3/mockwebserver/MockResponse;
- move-result-object p1
- goto :goto_0
- :cond_0
- const/4 p1, 0x0
- :goto_0
- invoke-virtual {p0, p1}, Lokhttp3/mockwebserver/QueueDispatcher;->setFailFast(Lokhttp3/mockwebserver/MockResponse;)V
- return-void
- .end method
- .method public shutdown()V
- .locals 2
- iget-object v0, p0, Lokhttp3/mockwebserver/QueueDispatcher;->responseQueue:Ljava/util/concurrent/BlockingQueue;
- sget-object v1, Lokhttp3/mockwebserver/QueueDispatcher;->DEAD_LETTER:Lokhttp3/mockwebserver/MockResponse;
- invoke-interface {v0, v1}, Ljava/util/concurrent/BlockingQueue;->add(Ljava/lang/Object;)Z
- return-void
- .end method
|