123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920 |
- .class public final Lokhttp3/internal/http2/Http2Server;
- .super Lokhttp3/internal/http2/Http2Connection$Listener;
- .source ""
- # static fields
- .field static final logger:Ljava/util/logging/Logger;
- # instance fields
- .field private final baseDirectory:Ljava/io/File;
- .field private final sslSocketFactory:Ljavax/net/ssl/SSLSocketFactory;
- # direct methods
- .method static constructor <clinit>()V
- .locals 1
- const-class v0, Lokhttp3/internal/http2/Http2Server;
- 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/internal/http2/Http2Server;->logger:Ljava/util/logging/Logger;
- return-void
- .end method
- .method public constructor <init>(Ljava/io/File;Ljavax/net/ssl/SSLSocketFactory;)V
- .locals 0
- invoke-direct {p0}, Lokhttp3/internal/http2/Http2Connection$Listener;-><init>()V
- iput-object p1, p0, Lokhttp3/internal/http2/Http2Server;->baseDirectory:Ljava/io/File;
- iput-object p2, p0, Lokhttp3/internal/http2/Http2Server;->sslSocketFactory:Ljavax/net/ssl/SSLSocketFactory;
- return-void
- .end method
- .method private contentType(Ljava/io/File;)Ljava/lang/String;
- .locals 3
- invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object v0
- const-string v1, ".css"
- invoke-virtual {v0, v1}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
- move-result v0
- if-eqz v0, :cond_0
- const-string p1, "text/css"
- return-object p1
- :cond_0
- invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object v0
- const-string v1, ".gif"
- invoke-virtual {v0, v1}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
- move-result v0
- if-eqz v0, :cond_1
- const-string p1, "image/gif"
- return-object p1
- :cond_1
- invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object v0
- const-string v1, ".html"
- invoke-virtual {v0, v1}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
- move-result v0
- if-eqz v0, :cond_2
- const-string p1, "text/html"
- return-object p1
- :cond_2
- invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object v0
- const-string v1, ".jpeg"
- invoke-virtual {v0, v1}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
- move-result v0
- const-string v1, "image/jpeg"
- if-eqz v0, :cond_3
- return-object v1
- :cond_3
- invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object v0
- const-string v2, ".jpg"
- invoke-virtual {v0, v2}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
- move-result v0
- if-eqz v0, :cond_4
- return-object v1
- :cond_4
- invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object v0
- const-string v1, ".js"
- invoke-virtual {v0, v1}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
- move-result v0
- if-eqz v0, :cond_5
- const-string p1, "application/javascript"
- return-object p1
- :cond_5
- invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object p1
- const-string v0, ".png"
- invoke-virtual {p1, v0}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z
- move-result p1
- if-eqz p1, :cond_6
- const-string p1, "image/png"
- return-object p1
- :cond_6
- const-string p1, "text/plain"
- return-object p1
- .end method
- .method private doSsl(Ljava/net/Socket;)Ljavax/net/ssl/SSLSocket;
- .locals 4
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- iget-object v0, p0, Lokhttp3/internal/http2/Http2Server;->sslSocketFactory:Ljavax/net/ssl/SSLSocketFactory;
- invoke-virtual {p1}, Ljava/net/Socket;->getInetAddress()Ljava/net/InetAddress;
- move-result-object v1
- invoke-virtual {v1}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {p1}, Ljava/net/Socket;->getPort()I
- move-result v2
- const/4 v3, 0x1
- invoke-virtual {v0, p1, v1, v2, v3}, Ljavax/net/ssl/SSLSocketFactory;->createSocket(Ljava/net/Socket;Ljava/lang/String;IZ)Ljava/net/Socket;
- move-result-object p1
- check-cast p1, Ljavax/net/ssl/SSLSocket;
- const/4 v0, 0x0
- invoke-virtual {p1, v0}, Ljavax/net/ssl/SSLSocket;->setUseClientMode(Z)V
- invoke-static {}, Lokhttp3/internal/platform/Platform;->get()Lokhttp3/internal/platform/Platform;
- move-result-object v0
- sget-object v1, Lokhttp3/Protocol;->HTTP_2:Lokhttp3/Protocol;
- invoke-static {v1}, Ljava/util/Collections;->singletonList(Ljava/lang/Object;)Ljava/util/List;
- move-result-object v1
- const/4 v2, 0x0
- invoke-virtual {v0, p1, v2, v1}, Lokhttp3/internal/platform/Platform;->configureTlsExtensions(Ljavax/net/ssl/SSLSocket;Ljava/lang/String;Ljava/util/List;)V
- invoke-virtual {p1}, Ljavax/net/ssl/SSLSocket;->startHandshake()V
- return-object p1
- .end method
- .method public static varargs main([Ljava/lang/String;)V
- .locals 3
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/lang/Exception;
- }
- .end annotation
- array-length v0, p0
- const/4 v1, 0x1
- if-ne v0, v1, :cond_1
- const/4 v0, 0x0
- aget-object v1, p0, v0
- const-string v2, "-"
- invoke-virtual {v1, v2}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
- move-result v1
- if-eqz v1, :cond_0
- goto :goto_0
- :cond_0
- new-instance v1, Lokhttp3/internal/http2/Http2Server;
- new-instance v2, Ljava/io/File;
- aget-object p0, p0, v0
- invoke-direct {v2, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V
- invoke-static {}, Lokhttp3/internal/tls/SslClient;->localhost()Lokhttp3/internal/tls/SslClient;
- move-result-object p0
- iget-object p0, p0, Lokhttp3/internal/tls/SslClient;->sslContext:Ljavax/net/ssl/SSLContext;
- invoke-virtual {p0}, Ljavax/net/ssl/SSLContext;->getSocketFactory()Ljavax/net/ssl/SSLSocketFactory;
- move-result-object p0
- invoke-direct {v1, v2, p0}, Lokhttp3/internal/http2/Http2Server;-><init>(Ljava/io/File;Ljavax/net/ssl/SSLSocketFactory;)V
- invoke-direct {v1}, Lokhttp3/internal/http2/Http2Server;->run()V
- return-void
- :cond_1
- :goto_0
- sget-object p0, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Usage: Http2Server <base directory>"
- invoke-virtual {p0, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
- return-void
- .end method
- .method private run()V
- .locals 8
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/lang/Exception;
- }
- .end annotation
- new-instance v0, Ljava/net/ServerSocket;
- const/16 v1, 0x22b8
- invoke-direct {v0, v1}, Ljava/net/ServerSocket;-><init>(I)V
- const/4 v1, 0x1
- invoke-virtual {v0, v1}, Ljava/net/ServerSocket;->setReuseAddress(Z)V
- :goto_0
- const/4 v1, 0x0
- :try_start_0
- invoke-virtual {v0}, Ljava/net/ServerSocket;->accept()Ljava/net/Socket;
- move-result-object v2
- :try_end_0
- .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_3
- .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_2
- :try_start_1
- invoke-direct {p0, v2}, Lokhttp3/internal/http2/Http2Server;->doSsl(Ljava/net/Socket;)Ljavax/net/ssl/SSLSocket;
- move-result-object v3
- invoke-static {}, Lokhttp3/internal/platform/Platform;->get()Lokhttp3/internal/platform/Platform;
- move-result-object v4
- invoke-virtual {v4, v3}, Lokhttp3/internal/platform/Platform;->getSelectedProtocol(Ljavax/net/ssl/SSLSocket;)Ljava/lang/String;
- move-result-object v4
- if-eqz v4, :cond_0
- invoke-static {v4}, Lokhttp3/Protocol;->get(Ljava/lang/String;)Lokhttp3/Protocol;
- move-result-object v1
- :cond_0
- sget-object v4, Lokhttp3/Protocol;->HTTP_2:Lokhttp3/Protocol;
- if-ne v1, v4, :cond_1
- new-instance v1, Lokhttp3/internal/http2/Http2Connection$Builder;
- const/4 v4, 0x0
- invoke-direct {v1, v4}, Lokhttp3/internal/http2/Http2Connection$Builder;-><init>(Z)V
- invoke-virtual {v1, v3}, Lokhttp3/internal/http2/Http2Connection$Builder;->socket(Ljava/net/Socket;)Lokhttp3/internal/http2/Http2Connection$Builder;
- move-result-object v1
- invoke-virtual {v1, p0}, Lokhttp3/internal/http2/Http2Connection$Builder;->listener(Lokhttp3/internal/http2/Http2Connection$Listener;)Lokhttp3/internal/http2/Http2Connection$Builder;
- move-result-object v1
- invoke-virtual {v1}, Lokhttp3/internal/http2/Http2Connection$Builder;->build()Lokhttp3/internal/http2/Http2Connection;
- move-result-object v1
- invoke-virtual {v1}, Lokhttp3/internal/http2/Http2Connection;->start()V
- goto :goto_0
- :cond_1
- new-instance v3, Ljava/net/ProtocolException;
- new-instance v4, Ljava/lang/StringBuilder;
- invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
- const-string v5, "Protocol "
- invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v4, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
- const-string v1, " unsupported"
- invoke-virtual {v4, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v1
- invoke-direct {v3, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v3
- :try_end_1
- .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1
- .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0
- :catch_0
- move-exception v1
- goto :goto_1
- :catch_1
- move-exception v1
- goto :goto_2
- :catch_2
- move-exception v2
- move-object v7, v2
- move-object v2, v1
- move-object v1, v7
- :goto_1
- sget-object v3, Lokhttp3/internal/http2/Http2Server;->logger:Ljava/util/logging/Logger;
- sget-object v4, Ljava/util/logging/Level;->WARNING:Ljava/util/logging/Level;
- const-string v5, "Http2Server unexpected failure"
- invoke-virtual {v3, v4, v5, v1}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
- goto :goto_3
- :catch_3
- move-exception v2
- move-object v7, v2
- move-object v2, v1
- move-object v1, v7
- :goto_2
- sget-object v3, Lokhttp3/internal/http2/Http2Server;->logger:Ljava/util/logging/Logger;
- sget-object v4, Ljava/util/logging/Level;->INFO:Ljava/util/logging/Level;
- new-instance v5, Ljava/lang/StringBuilder;
- invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V
- const-string v6, "Http2Server connection failure: "
- invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v5, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
- invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v3, v4, v1}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;)V
- :goto_3
- invoke-static {v2}, Lokhttp3/internal/Util;->closeQuietly(Ljava/net/Socket;)V
- goto :goto_0
- .end method
- .method private send404(Lokhttp3/internal/http2/Http2Stream;Ljava/lang/String;)V
- .locals 5
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- const/4 v0, 0x3
- new-array v0, v0, [Lokhttp3/internal/http2/Header;
- new-instance v1, Lokhttp3/internal/http2/Header;
- const-string v2, ":status"
- const-string v3, "404"
- invoke-direct {v1, v2, v3}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v2, 0x0
- aput-object v1, v0, v2
- new-instance v1, Lokhttp3/internal/http2/Header;
- const-string v2, ":version"
- const-string v3, "HTTP/1.1"
- invoke-direct {v1, v2, v3}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v2, 0x1
- aput-object v1, v0, v2
- new-instance v1, Lokhttp3/internal/http2/Header;
- const-string v3, "content-type"
- const-string v4, "text/plain"
- invoke-direct {v1, v3, v4}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v3, 0x2
- aput-object v1, v0, v3
- invoke-static {v0}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;
- move-result-object v0
- invoke-virtual {p1, v0, v2}, Lokhttp3/internal/http2/Http2Stream;->sendResponseHeaders(Ljava/util/List;Z)V
- invoke-virtual {p1}, Lokhttp3/internal/http2/Http2Stream;->getSink()Lokio/Sink;
- move-result-object p1
- invoke-static {p1}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink;
- move-result-object p1
- new-instance v0, Ljava/lang/StringBuilder;
- invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
- const-string v1, "Not found: "
- invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p2
- invoke-interface {p1, p2}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
- invoke-interface {p1}, Lokio/Sink;->close()V
- return-void
- .end method
- .method private serveDirectory(Lokhttp3/internal/http2/Http2Stream;[Ljava/io/File;)V
- .locals 6
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- const/4 v0, 0x3
- new-array v0, v0, [Lokhttp3/internal/http2/Header;
- new-instance v1, Lokhttp3/internal/http2/Header;
- const-string v2, ":status"
- const-string v3, "200"
- invoke-direct {v1, v2, v3}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v2, 0x0
- aput-object v1, v0, v2
- new-instance v1, Lokhttp3/internal/http2/Header;
- const-string v3, ":version"
- const-string v4, "HTTP/1.1"
- invoke-direct {v1, v3, v4}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v3, 0x1
- aput-object v1, v0, v3
- new-instance v1, Lokhttp3/internal/http2/Header;
- const-string v4, "content-type"
- const-string v5, "text/html; charset=UTF-8"
- invoke-direct {v1, v4, v5}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v4, 0x2
- aput-object v1, v0, v4
- invoke-static {v0}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;
- move-result-object v0
- invoke-virtual {p1, v0, v3}, Lokhttp3/internal/http2/Http2Stream;->sendResponseHeaders(Ljava/util/List;Z)V
- invoke-virtual {p1}, Lokhttp3/internal/http2/Http2Stream;->getSink()Lokio/Sink;
- move-result-object p1
- invoke-static {p1}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink;
- move-result-object p1
- array-length v0, p2
- :goto_0
- if-ge v2, v0, :cond_1
- aget-object v1, p2, v2
- invoke-virtual {v1}, Ljava/io/File;->isDirectory()Z
- move-result v3
- if-eqz v3, :cond_0
- new-instance v3, Ljava/lang/StringBuilder;
- invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
- invoke-virtual {v1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- const-string v1, "/"
- invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v1
- goto :goto_1
- :cond_0
- invoke-virtual {v1}, Ljava/io/File;->getName()Ljava/lang/String;
- move-result-object v1
- :goto_1
- new-instance v3, Ljava/lang/StringBuilder;
- invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
- const-string v4, "<a href=\'"
- invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- const-string v4, "\'>"
- invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- const-string v1, "</a><br>"
- invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v1
- invoke-interface {p1, v1}, Lokio/BufferedSink;->writeUtf8(Ljava/lang/String;)Lokio/BufferedSink;
- add-int/lit8 v2, v2, 0x1
- goto :goto_0
- :cond_1
- invoke-interface {p1}, Lokio/Sink;->close()V
- return-void
- .end method
- .method private serveFile(Lokhttp3/internal/http2/Http2Stream;Ljava/io/File;)V
- .locals 5
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- const/4 v0, 0x3
- new-array v0, v0, [Lokhttp3/internal/http2/Header;
- new-instance v1, Lokhttp3/internal/http2/Header;
- const-string v2, ":status"
- const-string v3, "200"
- invoke-direct {v1, v2, v3}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v2, 0x0
- aput-object v1, v0, v2
- new-instance v1, Lokhttp3/internal/http2/Header;
- const-string v2, ":version"
- const-string v3, "HTTP/1.1"
- invoke-direct {v1, v2, v3}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v2, 0x1
- aput-object v1, v0, v2
- new-instance v1, Lokhttp3/internal/http2/Header;
- invoke-direct {p0, p2}, Lokhttp3/internal/http2/Http2Server;->contentType(Ljava/io/File;)Ljava/lang/String;
- move-result-object v3
- const-string v4, "content-type"
- invoke-direct {v1, v4, v3}, Lokhttp3/internal/http2/Header;-><init>(Ljava/lang/String;Ljava/lang/String;)V
- const/4 v3, 0x2
- aput-object v1, v0, v3
- invoke-static {v0}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;
- move-result-object v0
- invoke-virtual {p1, v0, v2}, Lokhttp3/internal/http2/Http2Stream;->sendResponseHeaders(Ljava/util/List;Z)V
- invoke-static {p2}, Lokio/Okio;->source(Ljava/io/File;)Lokio/Source;
- move-result-object p2
- :try_start_0
- invoke-virtual {p1}, Lokhttp3/internal/http2/Http2Stream;->getSink()Lokio/Sink;
- move-result-object p1
- invoke-static {p1}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink;
- move-result-object p1
- invoke-interface {p1, p2}, Lokio/BufferedSink;->writeAll(Lokio/Source;)J
- invoke-interface {p1}, Lokio/Sink;->close()V
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- invoke-static {p2}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- return-void
- :catchall_0
- move-exception p1
- invoke-static {p2}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- throw p1
- .end method
- # virtual methods
- .method public onStream(Lokhttp3/internal/http2/Http2Stream;)V
- .locals 6
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- const/4 v0, 0x0
- :try_start_0
- invoke-virtual {p1}, Lokhttp3/internal/http2/Http2Stream;->getRequestHeaders()Ljava/util/List;
- move-result-object v1
- const/4 v2, 0x0
- invoke-interface {v1}, Ljava/util/List;->size()I
- move-result v3
- :goto_0
- if-ge v2, v3, :cond_1
- invoke-interface {v1, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;
- move-result-object v4
- check-cast v4, Lokhttp3/internal/http2/Header;
- iget-object v4, v4, Lokhttp3/internal/http2/Header;->name:Lokio/ByteString;
- sget-object v5, Lokhttp3/internal/http2/Header;->TARGET_PATH:Lokio/ByteString;
- invoke-virtual {v4, v5}, Lokio/ByteString;->equals(Ljava/lang/Object;)Z
- move-result v4
- if-eqz v4, :cond_0
- invoke-interface {v1, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;
- move-result-object v1
- check-cast v1, Lokhttp3/internal/http2/Header;
- iget-object v1, v1, Lokhttp3/internal/http2/Header;->value:Lokio/ByteString;
- invoke-virtual {v1}, Lokio/ByteString;->utf8()Ljava/lang/String;
- move-result-object v1
- goto :goto_1
- :cond_0
- add-int/lit8 v2, v2, 0x1
- goto :goto_0
- :cond_1
- move-object v1, v0
- :goto_1
- if-eqz v1, :cond_4
- new-instance v2, Ljava/io/File;
- new-instance v3, Ljava/lang/StringBuilder;
- invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
- iget-object v4, p0, Lokhttp3/internal/http2/Http2Server;->baseDirectory:Ljava/io/File;
- invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
- invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v3
- invoke-direct {v2, v3}, Ljava/io/File;-><init>(Ljava/lang/String;)V
- invoke-virtual {v2}, Ljava/io/File;->isDirectory()Z
- move-result v3
- if-eqz v3, :cond_2
- invoke-virtual {v2}, Ljava/io/File;->listFiles()[Ljava/io/File;
- move-result-object v1
- invoke-direct {p0, p1, v1}, Lokhttp3/internal/http2/Http2Server;->serveDirectory(Lokhttp3/internal/http2/Http2Stream;[Ljava/io/File;)V
- goto :goto_2
- :cond_2
- invoke-virtual {v2}, Ljava/io/File;->exists()Z
- move-result v3
- if-eqz v3, :cond_3
- invoke-direct {p0, p1, v2}, Lokhttp3/internal/http2/Http2Server;->serveFile(Lokhttp3/internal/http2/Http2Stream;Ljava/io/File;)V
- goto :goto_2
- :cond_3
- invoke-direct {p0, p1, v1}, Lokhttp3/internal/http2/Http2Server;->send404(Lokhttp3/internal/http2/Http2Stream;Ljava/lang/String;)V
- goto :goto_2
- :cond_4
- new-instance p1, Ljava/lang/AssertionError;
- invoke-direct {p1}, Ljava/lang/AssertionError;-><init>()V
- throw p1
- :try_end_0
- .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
- :catch_0
- move-exception p1
- invoke-static {}, Lokhttp3/internal/platform/Platform;->get()Lokhttp3/internal/platform/Platform;
- move-result-object v1
- const/4 v2, 0x4
- new-instance v3, Ljava/lang/StringBuilder;
- invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
- const-string v4, "Failure serving Http2Stream: "
- invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p1}, Ljava/io/IOException;->getMessage()Ljava/lang/String;
- move-result-object p1
- invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p1
- invoke-virtual {v1, v2, p1, v0}, Lokhttp3/internal/platform/Platform;->log(ILjava/lang/String;Ljava/lang/Throwable;)V
- :goto_2
- return-void
- .end method
|