Spdy3.java
19.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
package com.squareup.okhttp.internal.framed;
import com.squareup.okhttp.Protocol;
import com.squareup.okhttp.internal.Util;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.ProtocolException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.zip.Deflater;
import okio.Buffer;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.ByteString;
import okio.DeflaterSink;
import okio.Okio;
public final class Spdy3
implements Variant
{
static final byte[] DICTIONARY;
static final int FLAG_FIN = 1;
static final int FLAG_UNIDIRECTIONAL = 2;
static final int TYPE_DATA = 0;
static final int TYPE_GOAWAY = 7;
static final int TYPE_HEADERS = 8;
static final int TYPE_PING = 6;
static final int TYPE_RST_STREAM = 3;
static final int TYPE_SETTINGS = 4;
static final int TYPE_SYN_REPLY = 2;
static final int TYPE_SYN_STREAM = 1;
static final int TYPE_WINDOW_UPDATE = 9;
static final int VERSION = 3;
static
{
try
{
DICTIONARY = "\000\000\000\007options\000\000\000\004head\000\000\000\004post\000\000\000\003put\000\000\000\006delete\000\000\000\005trace\000\000\000\006accept\000\000\000\016accept-charset\000\000\000\017accept-encoding\000\000\000\017accept-language\000\000\000\raccept-ranges\000\000\000\003age\000\000\000\005allow\000\000\000\rauthorization\000\000\000\rcache-control\000\000\000\nconnection\000\000\000\fcontent-base\000\000\000\020content-encoding\000\000\000\020content-language\000\000\000\016content-length\000\000\000\020content-location\000\000\000\013content-md5\000\000\000\rcontent-range\000\000\000\fcontent-type\000\000\000\004date\000\000\000\004etag\000\000\000\006expect\000\000\000\007expires\000\000\000\004from\000\000\000\004host\000\000\000\bif-match\000\000\000\021if-modified-since\000\000\000\rif-none-match\000\000\000\bif-range\000\000\000\023if-unmodified-since\000\000\000\rlast-modified\000\000\000\blocation\000\000\000\fmax-forwards\000\000\000\006pragma\000\000\000\022proxy-authenticate\000\000\000\023proxy-authorization\000\000\000\005range\000\000\000\007referer\000\000\000\013retry-after\000\000\000\006server\000\000\000\002te\000\000\000\007trailer\000\000\000\021transfer-encoding\000\000\000\007upgrade\000\000\000\nuser-agent\000\000\000\004vary\000\000\000\003via\000\000\000\007warning\000\000\000\020www-authenticate\000\000\000\006method\000\000\000\003get\000\000\000\006status\000\000\000\006200 OK\000\000\000\007version\000\000\000\bHTTP/1.1\000\000\000\003url\000\000\000\006public\000\000\000\nset-cookie\000\000\000\nkeep-alive\000\000\000\006origin100101201202205206300302303304305306307402405406407408409410411412413414415416417502504505203 Non-Authoritative Information204 No Content301 Moved Permanently400 Bad Request401 Unauthorized403 Forbidden404 Not Found500 Internal Server Error501 Not Implemented503 Service UnavailableJan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec 00:00:00 Mon, Tue, Wed, Thu, Fri, Sat, Sun, GMTchunked,text/html,image/png,image/jpg,image/gif,application/xml,application/xhtml+xml,text/plain,text/javascript,publicprivatemax-age=gzip,deflate,sdchcharset=utf-8charset=iso-8859-1,utf-,*,enq=0.".getBytes(Util.UTF_8.name());
return;
}
catch (UnsupportedEncodingException localUnsupportedEncodingException)
{
throw new AssertionError();
}
}
public final Protocol getProtocol()
{
return Protocol.SPDY_3;
}
public final FrameReader newReader(BufferedSource paramBufferedSource, boolean paramBoolean)
{
return new Reader(paramBufferedSource, paramBoolean);
}
public final FrameWriter newWriter(BufferedSink paramBufferedSink, boolean paramBoolean)
{
return new Writer(paramBufferedSink, paramBoolean);
}
static final class Reader
implements FrameReader
{
private final boolean client;
private final NameValueBlockReader headerBlockReader;
private final BufferedSource source;
Reader(BufferedSource paramBufferedSource, boolean paramBoolean)
{
this.source = paramBufferedSource;
this.headerBlockReader = new NameValueBlockReader(this.source);
this.client = paramBoolean;
}
private static IOException ioException(String paramString, Object... paramVarArgs)
throws IOException
{
throw new IOException(String.format(paramString, paramVarArgs));
}
private void readGoAway(FrameReader.Handler paramHandler, int paramInt1, int paramInt2)
throws IOException
{
if (paramInt2 != 8) {
throw ioException("TYPE_GOAWAY length: %d != 8", new Object[] { Integer.valueOf(paramInt2) });
}
paramInt1 = this.source.readInt();
paramInt2 = this.source.readInt();
ErrorCode localErrorCode = ErrorCode.fromSpdyGoAway(paramInt2);
if (localErrorCode == null) {
throw ioException("TYPE_GOAWAY unexpected error code: %d", new Object[] { Integer.valueOf(paramInt2) });
}
paramHandler.goAway(paramInt1 & 0x7FFFFFFF, localErrorCode, ByteString.EMPTY);
}
private void readHeaders(FrameReader.Handler paramHandler, int paramInt1, int paramInt2)
throws IOException
{
paramHandler.headers(false, false, this.source.readInt() & 0x7FFFFFFF, -1, this.headerBlockReader.readNameValueBlock(paramInt2 - 4), HeadersMode.SPDY_HEADERS);
}
private void readPing(FrameReader.Handler paramHandler, int paramInt1, int paramInt2)
throws IOException
{
boolean bool2 = true;
if (paramInt2 != 4) {
throw ioException("TYPE_PING length: %d != 4", new Object[] { Integer.valueOf(paramInt2) });
}
paramInt1 = this.source.readInt();
boolean bool3 = this.client;
if ((paramInt1 & 0x1) == 1)
{
bool1 = true;
if (bool3 != bool1) {
break label79;
}
}
label79:
for (boolean bool1 = bool2;; bool1 = false)
{
paramHandler.ping(bool1, paramInt1, 0);
return;
bool1 = false;
break;
}
}
private void readRstStream(FrameReader.Handler paramHandler, int paramInt1, int paramInt2)
throws IOException
{
if (paramInt2 != 8) {
throw ioException("TYPE_RST_STREAM length: %d != 8", new Object[] { Integer.valueOf(paramInt2) });
}
paramInt1 = this.source.readInt();
paramInt2 = this.source.readInt();
ErrorCode localErrorCode = ErrorCode.fromSpdy3Rst(paramInt2);
if (localErrorCode == null) {
throw ioException("TYPE_RST_STREAM unexpected error code: %d", new Object[] { Integer.valueOf(paramInt2) });
}
paramHandler.rstStream(paramInt1 & 0x7FFFFFFF, localErrorCode);
}
private void readSettings(FrameReader.Handler paramHandler, int paramInt1, int paramInt2)
throws IOException
{
boolean bool = true;
int i = this.source.readInt();
if (paramInt2 != i * 8 + 4) {
throw ioException("TYPE_SETTINGS length: %d != 4 + 8 * %d", new Object[] { Integer.valueOf(paramInt2), Integer.valueOf(i) });
}
Settings localSettings = new Settings();
paramInt2 = 0;
while (paramInt2 < i)
{
int j = this.source.readInt();
localSettings.set(j & 0xFFFFFF, (0xFF000000 & j) >>> 24, this.source.readInt());
paramInt2 += 1;
}
if ((paramInt1 & 0x1) != 0) {}
for (;;)
{
paramHandler.settings(bool, localSettings);
return;
bool = false;
}
}
private void readSynReply(FrameReader.Handler paramHandler, int paramInt1, int paramInt2)
throws IOException
{
int i = this.source.readInt();
List localList = this.headerBlockReader.readNameValueBlock(paramInt2 - 4);
if ((paramInt1 & 0x1) != 0) {}
for (boolean bool = true;; bool = false)
{
paramHandler.headers(false, bool, i & 0x7FFFFFFF, -1, localList, HeadersMode.SPDY_REPLY);
return;
}
}
private void readSynStream(FrameReader.Handler paramHandler, int paramInt1, int paramInt2)
throws IOException
{
boolean bool2 = true;
int i = this.source.readInt();
int j = this.source.readInt();
this.source.readShort();
List localList = this.headerBlockReader.readNameValueBlock(paramInt2 - 10);
boolean bool1;
if ((paramInt1 & 0x1) != 0)
{
bool1 = true;
if ((paramInt1 & 0x2) == 0) {
break label95;
}
}
for (;;)
{
paramHandler.headers(bool2, bool1, i & 0x7FFFFFFF, j & 0x7FFFFFFF, localList, HeadersMode.SPDY_SYN_STREAM);
return;
bool1 = false;
break;
label95:
bool2 = false;
}
}
private void readWindowUpdate(FrameReader.Handler paramHandler, int paramInt1, int paramInt2)
throws IOException
{
if (paramInt2 != 8) {
throw ioException("TYPE_WINDOW_UPDATE length: %d != 8", new Object[] { Integer.valueOf(paramInt2) });
}
paramInt1 = this.source.readInt();
long l = this.source.readInt() & 0x7FFFFFFF;
if (l == 0L) {
throw ioException("windowSizeIncrement was 0", new Object[] { Long.valueOf(l) });
}
paramHandler.windowUpdate(paramInt1 & 0x7FFFFFFF, l);
}
public final void close()
throws IOException
{
this.headerBlockReader.close();
}
public final boolean nextFrame(FrameReader.Handler paramHandler)
throws IOException
{
boolean bool = false;
int j;
int k;
int m;
for (;;)
{
try
{
j = this.source.readInt();
k = this.source.readInt();
if ((0x80000000 & j) != 0)
{
i = 1;
m = (0xFF000000 & k) >>> 24;
k &= 0xFFFFFF;
if (i == 0) {
break label254;
}
i = (0x7FFF0000 & j) >>> 16;
if (i == 3) {
break;
}
throw new ProtocolException("version != 3: " + i);
}
}
catch (IOException paramHandler)
{
return false;
}
int i = 0;
}
switch (0xFFFF & j)
{
case 5:
default:
this.source.skip(k);
return true;
case 1:
readSynStream(paramHandler, m, k);
return true;
case 2:
readSynReply(paramHandler, m, k);
return true;
case 3:
readRstStream(paramHandler, m, k);
return true;
case 4:
readSettings(paramHandler, m, k);
return true;
case 6:
readPing(paramHandler, m, k);
return true;
case 7:
readGoAway(paramHandler, m, k);
return true;
case 8:
readHeaders(paramHandler, m, k);
return true;
}
readWindowUpdate(paramHandler, m, k);
return true;
label254:
if ((m & 0x1) != 0) {
bool = true;
}
paramHandler.data(bool, 0x7FFFFFFF & j, this.source, k);
return true;
}
public final void readConnectionPreface() {}
}
static final class Writer
implements FrameWriter
{
private final boolean client;
private boolean closed;
private final Buffer headerBlockBuffer;
private final BufferedSink headerBlockOut;
private final BufferedSink sink;
Writer(BufferedSink paramBufferedSink, boolean paramBoolean)
{
this.sink = paramBufferedSink;
this.client = paramBoolean;
paramBufferedSink = new Deflater();
paramBufferedSink.setDictionary(Spdy3.DICTIONARY);
this.headerBlockBuffer = new Buffer();
this.headerBlockOut = Okio.buffer(new DeflaterSink(this.headerBlockBuffer, paramBufferedSink));
}
private void writeNameValueBlockToBuffer(List<Header> paramList)
throws IOException
{
this.headerBlockOut.writeInt(paramList.size());
int j = paramList.size();
int i = 0;
while (i < j)
{
ByteString localByteString = ((Header)paramList.get(i)).name;
this.headerBlockOut.writeInt(localByteString.size());
this.headerBlockOut.write(localByteString);
localByteString = ((Header)paramList.get(i)).value;
this.headerBlockOut.writeInt(localByteString.size());
this.headerBlockOut.write(localByteString);
i += 1;
}
this.headerBlockOut.flush();
}
public final void ackSettings(Settings paramSettings) {}
public final void close()
throws IOException
{
try
{
this.closed = true;
Util.closeAll(this.sink, this.headerBlockOut);
return;
}
finally
{
localObject = finally;
throw ((Throwable)localObject);
}
}
public final void connectionPreface() {}
public final void data(boolean paramBoolean, int paramInt1, Buffer paramBuffer, int paramInt2)
throws IOException
{
if (paramBoolean) {}
for (int i = 1;; i = 0) {
try
{
sendDataFrame(paramInt1, i, paramBuffer, paramInt2);
return;
}
finally {}
}
}
public final void flush()
throws IOException
{
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
this.sink.flush();
}
public final void goAway(int paramInt, ErrorCode paramErrorCode, byte[] paramArrayOfByte)
throws IOException
{
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
if (paramErrorCode.spdyGoAwayCode == -1) {
throw new IllegalArgumentException("errorCode.spdyGoAwayCode == -1");
}
this.sink.writeInt(-2147287033);
this.sink.writeInt(8);
this.sink.writeInt(paramInt);
this.sink.writeInt(paramErrorCode.spdyGoAwayCode);
this.sink.flush();
}
public final void headers(int paramInt, List<Header> paramList)
throws IOException
{
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
writeNameValueBlockToBuffer(paramList);
int i = (int)(this.headerBlockBuffer.size() + 4L);
this.sink.writeInt(-2147287032);
this.sink.writeInt(i & 0xFFFFFF | 0x0);
this.sink.writeInt(0x7FFFFFFF & paramInt);
this.sink.writeAll(this.headerBlockBuffer);
}
public final int maxDataLength()
{
return 16383;
}
public final void ping(boolean paramBoolean, int paramInt1, int paramInt2)
throws IOException
{
boolean bool2 = true;
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
boolean bool3 = this.client;
boolean bool1;
if ((paramInt1 & 0x1) == 1) {
bool1 = true;
}
for (;;)
{
if (paramBoolean != bool1) {
throw new IllegalArgumentException("payload != reply");
}
this.sink.writeInt(-2147287034);
this.sink.writeInt(4);
this.sink.writeInt(paramInt1);
this.sink.flush();
return;
for (;;)
{
if (bool3 == bool1) {
break label130;
}
bool1 = bool2;
break;
bool1 = false;
}
label130:
bool1 = false;
}
}
public final void pushPromise(int paramInt1, int paramInt2, List<Header> paramList)
throws IOException
{}
public final void rstStream(int paramInt, ErrorCode paramErrorCode)
throws IOException
{
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
if (paramErrorCode.spdyRstCode == -1) {
throw new IllegalArgumentException();
}
this.sink.writeInt(-2147287037);
this.sink.writeInt(8);
this.sink.writeInt(0x7FFFFFFF & paramInt);
this.sink.writeInt(paramErrorCode.spdyRstCode);
this.sink.flush();
}
final void sendDataFrame(int paramInt1, int paramInt2, Buffer paramBuffer, int paramInt3)
throws IOException
{
if (this.closed) {
throw new IOException("closed");
}
if (paramInt3 > 16777215L) {
throw new IllegalArgumentException("FRAME_TOO_LARGE max size is 16Mib: " + paramInt3);
}
this.sink.writeInt(0x7FFFFFFF & paramInt1);
this.sink.writeInt((paramInt2 & 0xFF) << 24 | 0xFFFFFF & paramInt3);
if (paramInt3 > 0) {
this.sink.write(paramBuffer, paramInt3);
}
}
public final void settings(Settings paramSettings)
throws IOException
{
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
int i = paramSettings.size();
this.sink.writeInt(-2147287036);
this.sink.writeInt(i * 8 + 4 & 0xFFFFFF | 0x0);
this.sink.writeInt(i);
i = 0;
for (;;)
{
if (i <= 10)
{
if (paramSettings.isSet(i))
{
int j = paramSettings.flags(i);
this.sink.writeInt((j & 0xFF) << 24 | i & 0xFFFFFF);
this.sink.writeInt(paramSettings.get(i));
}
}
else
{
this.sink.flush();
return;
}
i += 1;
}
}
public final void synReply(boolean paramBoolean, int paramInt, List<Header> paramList)
throws IOException
{
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
writeNameValueBlockToBuffer(paramList);
if (paramBoolean) {}
for (int i = 1;; i = 0)
{
int j = (int)(this.headerBlockBuffer.size() + 4L);
this.sink.writeInt(-2147287038);
this.sink.writeInt((i & 0xFF) << 24 | j & 0xFFFFFF);
this.sink.writeInt(0x7FFFFFFF & paramInt);
this.sink.writeAll(this.headerBlockBuffer);
this.sink.flush();
return;
}
}
public final void synStream(boolean paramBoolean1, boolean paramBoolean2, int paramInt1, int paramInt2, List<Header> paramList)
throws IOException
{
int j = 0;
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
writeNameValueBlockToBuffer(paramList);
int k = (int)(10L + this.headerBlockBuffer.size());
int i;
if (paramBoolean1) {
i = 1;
}
for (;;)
{
this.sink.writeInt(-2147287039);
this.sink.writeInt(((j | i) & 0xFF) << 24 | k & 0xFFFFFF);
this.sink.writeInt(paramInt1 & 0x7FFFFFFF);
this.sink.writeInt(paramInt2 & 0x7FFFFFFF);
this.sink.writeShort(0);
this.sink.writeAll(this.headerBlockBuffer);
this.sink.flush();
return;
i = 0;
if (paramBoolean2) {
j = 2;
}
}
}
public final void windowUpdate(int paramInt, long paramLong)
throws IOException
{
try
{
if (this.closed) {
throw new IOException("closed");
}
}
finally {}
if ((paramLong == 0L) || (paramLong > 2147483647L)) {
throw new IllegalArgumentException("windowSizeIncrement must be between 1 and 0x7fffffff: " + paramLong);
}
this.sink.writeInt(-2147287031);
this.sink.writeInt(8);
this.sink.writeInt(paramInt);
this.sink.writeInt((int)paramLong);
this.sink.flush();
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/internal/framed/Spdy3.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/