123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997 |
- .class final Lokhttp3/internal/ws/WebSocketReader;
- .super Ljava/lang/Object;
- .source ""
- # annotations
- .annotation system Ldalvik/annotation/MemberClasses;
- value = {
- Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- }
- .end annotation
- # instance fields
- .field closed:Z
- .field frameBytesRead:J
- .field final frameCallback:Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- .field frameLength:J
- .field final isClient:Z
- .field isControlFrame:Z
- .field isFinalFrame:Z
- .field isMasked:Z
- .field final maskBuffer:[B
- .field final maskKey:[B
- .field opcode:I
- .field final source:Lokio/BufferedSource;
- # direct methods
- .method constructor <init>(ZLokio/BufferedSource;Lokhttp3/internal/ws/WebSocketReader$FrameCallback;)V
- .locals 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- const/4 v0, 0x4
- new-array v0, v0, [B
- iput-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->maskKey:[B
- const/16 v0, 0x2000
- new-array v0, v0, [B
- iput-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- if-eqz p2, :cond_1
- if-eqz p3, :cond_0
- iput-boolean p1, p0, Lokhttp3/internal/ws/WebSocketReader;->isClient:Z
- iput-object p2, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- iput-object p3, p0, Lokhttp3/internal/ws/WebSocketReader;->frameCallback:Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- return-void
- :cond_0
- new-instance p1, Ljava/lang/NullPointerException;
- const-string p2, "frameCallback == null"
- invoke-direct {p1, p2}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
- throw p1
- :cond_1
- new-instance p1, Ljava/lang/NullPointerException;
- const-string p2, "source == null"
- invoke-direct {p1, p2}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
- throw p1
- .end method
- .method private readControlFrame()V
- .locals 11
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- new-instance v0, Lokio/Buffer;
- invoke-direct {v0}, Lokio/Buffer;-><init>()V
- iget-wide v1, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- iget-wide v3, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- cmp-long v5, v1, v3
- if-gez v5, :cond_2
- iget-boolean v1, p0, Lokhttp3/internal/ws/WebSocketReader;->isClient:Z
- if-eqz v1, :cond_0
- iget-object v1, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v1, v0, v3, v4}, Lokio/BufferedSource;->readFully(Lokio/Buffer;J)V
- goto :goto_1
- :cond_0
- :goto_0
- iget-wide v1, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- iget-wide v3, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- cmp-long v5, v1, v3
- if-gez v5, :cond_2
- sub-long/2addr v3, v1
- iget-object v1, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- array-length v1, v1
- int-to-long v1, v1
- invoke-static {v3, v4, v1, v2}, Ljava/lang/Math;->min(JJ)J
- move-result-wide v1
- long-to-int v2, v1
- iget-object v1, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- iget-object v3, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- const/4 v4, 0x0
- invoke-interface {v1, v3, v4, v2}, Lokio/BufferedSource;->read([BII)I
- move-result v1
- const/4 v2, -0x1
- if-eq v1, v2, :cond_1
- iget-object v5, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- int-to-long v2, v1
- iget-object v8, p0, Lokhttp3/internal/ws/WebSocketReader;->maskKey:[B
- iget-wide v9, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- move-wide v6, v2
- invoke-static/range {v5 .. v10}, Lokhttp3/internal/ws/WebSocketProtocol;->toggleMask([BJ[BJ)V
- iget-object v5, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- invoke-virtual {v0, v5, v4, v1}, Lokio/Buffer;->write([BII)Lokio/Buffer;
- iget-wide v4, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- add-long/2addr v4, v2
- iput-wide v4, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- goto :goto_0
- :cond_1
- new-instance v0, Ljava/io/EOFException;
- invoke-direct {v0}, Ljava/io/EOFException;-><init>()V
- throw v0
- :cond_2
- :goto_1
- iget v1, p0, Lokhttp3/internal/ws/WebSocketReader;->opcode:I
- packed-switch v1, :pswitch_data_0
- new-instance v0, Ljava/net/ProtocolException;
- new-instance v1, Ljava/lang/StringBuilder;
- invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
- const-string v2, "Unknown control opcode: "
- invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- iget v2, p0, Lokhttp3/internal/ws/WebSocketReader;->opcode:I
- invoke-static {v2}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;
- move-result-object v2
- invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v1
- invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v0
- :pswitch_0
- iget-object v1, p0, Lokhttp3/internal/ws/WebSocketReader;->frameCallback:Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- invoke-virtual {v0}, Lokio/Buffer;->readByteString()Lokio/ByteString;
- move-result-object v0
- invoke-interface {v1, v0}, Lokhttp3/internal/ws/WebSocketReader$FrameCallback;->onReadPong(Lokio/ByteString;)V
- goto :goto_3
- :pswitch_1
- iget-object v1, p0, Lokhttp3/internal/ws/WebSocketReader;->frameCallback:Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- invoke-virtual {v0}, Lokio/Buffer;->readByteString()Lokio/ByteString;
- move-result-object v0
- invoke-interface {v1, v0}, Lokhttp3/internal/ws/WebSocketReader$FrameCallback;->onReadPing(Lokio/ByteString;)V
- goto :goto_3
- :pswitch_2
- const/16 v1, 0x3ed
- invoke-virtual {v0}, Lokio/Buffer;->size()J
- move-result-wide v2
- const-wide/16 v4, 0x1
- cmp-long v6, v2, v4
- if-eqz v6, :cond_5
- const-wide/16 v4, 0x0
- cmp-long v6, v2, v4
- if-eqz v6, :cond_4
- invoke-virtual {v0}, Lokio/Buffer;->readShort()S
- move-result v1
- invoke-virtual {v0}, Lokio/Buffer;->readUtf8()Ljava/lang/String;
- move-result-object v0
- invoke-static {v1}, Lokhttp3/internal/ws/WebSocketProtocol;->closeCodeExceptionMessage(I)Ljava/lang/String;
- move-result-object v2
- if-nez v2, :cond_3
- goto :goto_2
- :cond_3
- new-instance v0, Ljava/net/ProtocolException;
- invoke-direct {v0, v2}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v0
- :cond_4
- const-string v0, ""
- :goto_2
- iget-object v2, p0, Lokhttp3/internal/ws/WebSocketReader;->frameCallback:Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- invoke-interface {v2, v1, v0}, Lokhttp3/internal/ws/WebSocketReader$FrameCallback;->onReadClose(ILjava/lang/String;)V
- const/4 v0, 0x1
- iput-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->closed:Z
- :goto_3
- return-void
- :cond_5
- new-instance v0, Ljava/net/ProtocolException;
- const-string v1, "Malformed close payload length of 1."
- invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- goto :goto_5
- :goto_4
- throw v0
- :goto_5
- goto :goto_4
- nop
- :pswitch_data_0
- .packed-switch 0x8
- :pswitch_2
- :pswitch_1
- :pswitch_0
- .end packed-switch
- .end method
- .method private readHeader()V
- .locals 7
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->closed:Z
- if-nez v0, :cond_11
- iget-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v0}, Lokio/Source;->timeout()Lokio/Timeout;
- move-result-object v0
- invoke-virtual {v0}, Lokio/Timeout;->timeoutNanos()J
- move-result-wide v0
- iget-object v2, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v2}, Lokio/Source;->timeout()Lokio/Timeout;
- move-result-object v2
- invoke-virtual {v2}, Lokio/Timeout;->clearTimeout()Lokio/Timeout;
- :try_start_0
- iget-object v2, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v2}, Lokio/BufferedSource;->readByte()B
- move-result v2
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- and-int/lit16 v2, v2, 0xff
- iget-object v3, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v3}, Lokio/Source;->timeout()Lokio/Timeout;
- move-result-object v3
- sget-object v4, Ljava/util/concurrent/TimeUnit;->NANOSECONDS:Ljava/util/concurrent/TimeUnit;
- invoke-virtual {v3, v0, v1, v4}, Lokio/Timeout;->timeout(JLjava/util/concurrent/TimeUnit;)Lokio/Timeout;
- and-int/lit8 v0, v2, 0xf
- iput v0, p0, Lokhttp3/internal/ws/WebSocketReader;->opcode:I
- and-int/lit16 v0, v2, 0x80
- const/4 v1, 0x1
- const/4 v3, 0x0
- if-eqz v0, :cond_0
- const/4 v0, 0x1
- goto :goto_0
- :cond_0
- const/4 v0, 0x0
- :goto_0
- iput-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isFinalFrame:Z
- and-int/lit8 v0, v2, 0x8
- if-eqz v0, :cond_1
- const/4 v0, 0x1
- goto :goto_1
- :cond_1
- const/4 v0, 0x0
- :goto_1
- iput-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isControlFrame:Z
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isControlFrame:Z
- if-eqz v0, :cond_3
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isFinalFrame:Z
- if-eqz v0, :cond_2
- goto :goto_2
- :cond_2
- new-instance v0, Ljava/net/ProtocolException;
- const-string v1, "Control frames must be final."
- invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v0
- :cond_3
- :goto_2
- and-int/lit8 v0, v2, 0x40
- if-eqz v0, :cond_4
- const/4 v0, 0x1
- goto :goto_3
- :cond_4
- const/4 v0, 0x0
- :goto_3
- and-int/lit8 v4, v2, 0x20
- if-eqz v4, :cond_5
- const/4 v4, 0x1
- goto :goto_4
- :cond_5
- const/4 v4, 0x0
- :goto_4
- and-int/lit8 v2, v2, 0x10
- if-eqz v2, :cond_6
- const/4 v2, 0x1
- goto :goto_5
- :cond_6
- const/4 v2, 0x0
- :goto_5
- if-nez v0, :cond_10
- if-nez v4, :cond_10
- if-nez v2, :cond_10
- iget-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v0}, Lokio/BufferedSource;->readByte()B
- move-result v0
- and-int/lit16 v0, v0, 0xff
- and-int/lit16 v2, v0, 0x80
- if-eqz v2, :cond_7
- goto :goto_6
- :cond_7
- const/4 v1, 0x0
- :goto_6
- iput-boolean v1, p0, Lokhttp3/internal/ws/WebSocketReader;->isMasked:Z
- iget-boolean v1, p0, Lokhttp3/internal/ws/WebSocketReader;->isMasked:Z
- iget-boolean v2, p0, Lokhttp3/internal/ws/WebSocketReader;->isClient:Z
- if-ne v1, v2, :cond_9
- new-instance v0, Ljava/net/ProtocolException;
- if-eqz v2, :cond_8
- const-string v1, "Server-sent frames must not be masked."
- goto :goto_7
- :cond_8
- const-string v1, "Client-sent frames must be masked."
- :goto_7
- invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v0
- :cond_9
- and-int/lit8 v0, v0, 0x7f
- int-to-long v0, v0
- iput-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- iget-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- const-wide/16 v2, 0x7e
- const-wide/16 v4, 0x0
- cmp-long v6, v0, v2
- if-nez v6, :cond_a
- iget-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v0}, Lokio/BufferedSource;->readShort()S
- move-result v0
- int-to-long v0, v0
- const-wide/32 v2, 0xffff
- and-long/2addr v0, v2
- iput-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- goto :goto_8
- :cond_a
- const-wide/16 v2, 0x7f
- cmp-long v6, v0, v2
- if-nez v6, :cond_c
- iget-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v0}, Lokio/BufferedSource;->readLong()J
- move-result-wide v0
- iput-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- iget-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- cmp-long v2, v0, v4
- if-ltz v2, :cond_b
- goto :goto_8
- :cond_b
- new-instance v0, Ljava/net/ProtocolException;
- new-instance v1, Ljava/lang/StringBuilder;
- invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
- const-string v2, "Frame length 0x"
- invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- iget-wide v2, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- invoke-static {v2, v3}, Ljava/lang/Long;->toHexString(J)Ljava/lang/String;
- move-result-object v2
- invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- const-string v2, " > 0x7FFFFFFFFFFFFFFF"
- invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v1
- invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v0
- :cond_c
- :goto_8
- iput-wide v4, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isControlFrame:Z
- if-eqz v0, :cond_e
- iget-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- const-wide/16 v2, 0x7d
- cmp-long v4, v0, v2
- if-gtz v4, :cond_d
- goto :goto_9
- :cond_d
- new-instance v0, Ljava/net/ProtocolException;
- const-string v1, "Control frame must be less than 125B."
- invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v0
- :cond_e
- :goto_9
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isMasked:Z
- if-eqz v0, :cond_f
- iget-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- iget-object v1, p0, Lokhttp3/internal/ws/WebSocketReader;->maskKey:[B
- invoke-interface {v0, v1}, Lokio/BufferedSource;->readFully([B)V
- :cond_f
- return-void
- :cond_10
- new-instance v0, Ljava/net/ProtocolException;
- const-string v1, "Reserved flags are unsupported."
- invoke-direct {v0, v1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v0
- :catchall_0
- move-exception v2
- iget-object v3, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v3}, Lokio/Source;->timeout()Lokio/Timeout;
- move-result-object v3
- sget-object v4, Ljava/util/concurrent/TimeUnit;->NANOSECONDS:Ljava/util/concurrent/TimeUnit;
- invoke-virtual {v3, v0, v1, v4}, Lokio/Timeout;->timeout(JLjava/util/concurrent/TimeUnit;)Lokio/Timeout;
- throw v2
- :cond_11
- new-instance v0, Ljava/io/IOException;
- const-string v1, "closed"
- invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
- throw v0
- .end method
- .method private readMessage(Lokio/Buffer;)V
- .locals 11
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- :goto_0
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->closed:Z
- if-nez v0, :cond_6
- iget-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- iget-wide v2, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- cmp-long v4, v0, v2
- if-nez v4, :cond_2
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isFinalFrame:Z
- if-eqz v0, :cond_0
- return-void
- :cond_0
- invoke-virtual {p0}, Lokhttp3/internal/ws/WebSocketReader;->readUntilNonControlFrame()V
- iget v0, p0, Lokhttp3/internal/ws/WebSocketReader;->opcode:I
- if-nez v0, :cond_1
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isFinalFrame:Z
- if-eqz v0, :cond_2
- iget-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- const-wide/16 v2, 0x0
- cmp-long v4, v0, v2
- if-nez v4, :cond_2
- return-void
- :cond_1
- new-instance p1, Ljava/net/ProtocolException;
- new-instance v0, Ljava/lang/StringBuilder;
- invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
- const-string v1, "Expected continuation opcode. Got: "
- invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- iget v1, p0, Lokhttp3/internal/ws/WebSocketReader;->opcode:I
- invoke-static {v1}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v0
- invoke-direct {p1, v0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw p1
- :cond_2
- iget-wide v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameLength:J
- iget-wide v2, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- sub-long/2addr v0, v2
- iget-boolean v2, p0, Lokhttp3/internal/ws/WebSocketReader;->isMasked:Z
- const-wide/16 v3, -0x1
- if-eqz v2, :cond_4
- iget-object v2, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- array-length v2, v2
- int-to-long v5, v2
- invoke-static {v0, v1, v5, v6}, Ljava/lang/Math;->min(JJ)J
- move-result-wide v0
- iget-object v2, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- iget-object v5, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- long-to-int v1, v0
- const/4 v0, 0x0
- invoke-interface {v2, v5, v0, v1}, Lokio/BufferedSource;->read([BII)I
- move-result v1
- int-to-long v1, v1
- cmp-long v5, v1, v3
- if-eqz v5, :cond_3
- iget-object v5, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- iget-object v8, p0, Lokhttp3/internal/ws/WebSocketReader;->maskKey:[B
- iget-wide v9, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- move-wide v6, v1
- invoke-static/range {v5 .. v10}, Lokhttp3/internal/ws/WebSocketProtocol;->toggleMask([BJ[BJ)V
- iget-object v3, p0, Lokhttp3/internal/ws/WebSocketReader;->maskBuffer:[B
- long-to-int v4, v1
- invoke-virtual {p1, v3, v0, v4}, Lokio/Buffer;->write([BII)Lokio/Buffer;
- goto :goto_1
- :cond_3
- new-instance p1, Ljava/io/EOFException;
- invoke-direct {p1}, Ljava/io/EOFException;-><init>()V
- throw p1
- :cond_4
- iget-object v2, p0, Lokhttp3/internal/ws/WebSocketReader;->source:Lokio/BufferedSource;
- invoke-interface {v2, p1, v0, v1}, Lokio/Source;->read(Lokio/Buffer;J)J
- move-result-wide v1
- cmp-long v0, v1, v3
- if-eqz v0, :cond_5
- :goto_1
- iget-wide v3, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- add-long/2addr v3, v1
- iput-wide v3, p0, Lokhttp3/internal/ws/WebSocketReader;->frameBytesRead:J
- goto/16 :goto_0
- :cond_5
- new-instance p1, Ljava/io/EOFException;
- invoke-direct {p1}, Ljava/io/EOFException;-><init>()V
- throw p1
- :cond_6
- new-instance p1, Ljava/io/IOException;
- const-string v0, "closed"
- invoke-direct {p1, v0}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
- goto :goto_3
- :goto_2
- throw p1
- :goto_3
- goto :goto_2
- .end method
- .method private readMessageFrame()V
- .locals 4
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- iget v0, p0, Lokhttp3/internal/ws/WebSocketReader;->opcode:I
- const/4 v1, 0x1
- if-eq v0, v1, :cond_1
- const/4 v2, 0x2
- if-ne v0, v2, :cond_0
- goto :goto_0
- :cond_0
- new-instance v1, Ljava/net/ProtocolException;
- new-instance v2, Ljava/lang/StringBuilder;
- invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
- const-string v3, "Unknown opcode: "
- invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-static {v0}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v0
- invoke-direct {v1, v0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v1
- :cond_1
- :goto_0
- new-instance v2, Lokio/Buffer;
- invoke-direct {v2}, Lokio/Buffer;-><init>()V
- invoke-direct {p0, v2}, Lokhttp3/internal/ws/WebSocketReader;->readMessage(Lokio/Buffer;)V
- if-ne v0, v1, :cond_2
- iget-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameCallback:Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- invoke-virtual {v2}, Lokio/Buffer;->readUtf8()Ljava/lang/String;
- move-result-object v1
- invoke-interface {v0, v1}, Lokhttp3/internal/ws/WebSocketReader$FrameCallback;->onReadMessage(Ljava/lang/String;)V
- goto :goto_1
- :cond_2
- iget-object v0, p0, Lokhttp3/internal/ws/WebSocketReader;->frameCallback:Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- invoke-virtual {v2}, Lokio/Buffer;->readByteString()Lokio/ByteString;
- move-result-object v1
- invoke-interface {v0, v1}, Lokhttp3/internal/ws/WebSocketReader$FrameCallback;->onReadMessage(Lokio/ByteString;)V
- :goto_1
- return-void
- .end method
- # virtual methods
- .method processNextFrame()V
- .locals 1
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- invoke-direct {p0}, Lokhttp3/internal/ws/WebSocketReader;->readHeader()V
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isControlFrame:Z
- if-eqz v0, :cond_0
- invoke-direct {p0}, Lokhttp3/internal/ws/WebSocketReader;->readControlFrame()V
- goto :goto_0
- :cond_0
- invoke-direct {p0}, Lokhttp3/internal/ws/WebSocketReader;->readMessageFrame()V
- :goto_0
- return-void
- .end method
- .method readUntilNonControlFrame()V
- .locals 1
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- :goto_0
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->closed:Z
- if-nez v0, :cond_1
- invoke-direct {p0}, Lokhttp3/internal/ws/WebSocketReader;->readHeader()V
- iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketReader;->isControlFrame:Z
- if-nez v0, :cond_0
- goto :goto_1
- :cond_0
- invoke-direct {p0}, Lokhttp3/internal/ws/WebSocketReader;->readControlFrame()V
- goto :goto_0
- :cond_1
- :goto_1
- return-void
- .end method
|