Call.java
13.3 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
package com.squareup.okhttp;
import com.squareup.okhttp.internal.NamedRunnable;
import com.squareup.okhttp.internal.http.HttpEngine;
import com.squareup.okhttp.internal.http.RequestException;
import com.squareup.okhttp.internal.http.RouteException;
import java.io.IOException;
import java.net.ProtocolException;
import java.util.List;
public class Call
{
volatile boolean canceled;
private final OkHttpClient client;
HttpEngine engine;
private boolean executed;
Request originalRequest;
protected Call(OkHttpClient paramOkHttpClient, Request paramRequest)
{
this.client = paramOkHttpClient.copyWithDefaults();
this.originalRequest = paramRequest;
}
private Response getResponseWithInterceptorChain(boolean paramBoolean)
throws IOException
{
return new ApplicationInterceptorChain(0, this.originalRequest, paramBoolean).proceed(this.originalRequest);
}
private String toLoggableString()
{
if (this.canceled) {}
for (String str = "canceled call";; str = "call")
{
HttpUrl localHttpUrl = this.originalRequest.httpUrl().resolve("/...");
return str + " to " + localHttpUrl;
}
}
public void cancel()
{
this.canceled = true;
if (this.engine != null) {
this.engine.disconnect();
}
}
public void enqueue(Callback paramCallback)
{
enqueue(paramCallback, false);
}
void enqueue(Callback paramCallback, boolean paramBoolean)
{
try
{
if (this.executed) {
throw new IllegalStateException("Already Executed");
}
}
finally {}
this.executed = true;
this.client.getDispatcher().enqueue(new AsyncCall(paramCallback, paramBoolean, null));
}
public Response execute()
throws IOException
{
try
{
if (this.executed) {
throw new IllegalStateException("Already Executed");
}
}
finally {}
this.executed = true;
try
{
this.client.getDispatcher().executed(this);
Response localResponse1 = getResponseWithInterceptorChain(false);
if (localResponse1 == null) {
throw new IOException("Canceled");
}
}
finally
{
this.client.getDispatcher().finished(this);
}
this.client.getDispatcher().finished(this);
return localResponse2;
}
Response getResponse(Request paramRequest, boolean paramBoolean)
throws IOException
{
Object localObject1 = paramRequest.body();
Object localObject2;
if (localObject1 != null)
{
paramRequest = paramRequest.newBuilder();
localObject2 = ((RequestBody)localObject1).contentType();
if (localObject2 != null) {
paramRequest.header("Content-Type", ((MediaType)localObject2).toString());
}
long l = ((RequestBody)localObject1).contentLength();
if (l != -1L)
{
paramRequest.header("Content-Length", Long.toString(l));
paramRequest.removeHeader("Transfer-Encoding");
paramRequest = paramRequest.build();
}
}
for (;;)
{
this.engine = new HttpEngine(this.client, paramRequest, false, false, paramBoolean, null, null, null, null);
int i = 0;
for (;;)
{
if (this.canceled)
{
this.engine.releaseConnection();
throw new IOException("Canceled");
paramRequest.header("Transfer-Encoding", "chunked");
paramRequest.removeHeader("Content-Length");
break;
}
try
{
this.engine.sendRequest();
this.engine.readResponse();
paramRequest = this.engine.getResponse();
localObject1 = this.engine.followUpRequest();
if (localObject1 == null)
{
if (!paramBoolean) {
this.engine.releaseConnection();
}
return paramRequest;
}
}
catch (RequestException paramRequest)
{
throw paramRequest.getCause();
}
catch (RouteException paramRequest)
{
localObject1 = this.engine.recover(paramRequest);
if (localObject1 != null)
{
this.engine = ((HttpEngine)localObject1);
continue;
}
throw paramRequest.getLastConnectException();
}
catch (IOException paramRequest)
{
localObject1 = this.engine.recover(paramRequest, null);
if (localObject1 != null)
{
this.engine = ((HttpEngine)localObject1);
continue;
}
throw paramRequest;
}
i += 1;
if (i > 20) {
throw new ProtocolException("Too many follow-up requests: " + i);
}
if (!this.engine.sameConnection(((Request)localObject1).httpUrl())) {
this.engine.releaseConnection();
}
localObject2 = this.engine.close();
this.engine = new HttpEngine(this.client, (Request)localObject1, false, false, paramBoolean, (Connection)localObject2, null, null, paramRequest);
}
}
}
public boolean isCanceled()
{
return this.canceled;
}
Object tag()
{
return this.originalRequest.tag();
}
class ApplicationInterceptorChain
implements Interceptor.Chain
{
private final boolean forWebSocket;
private final int index;
private final Request request;
ApplicationInterceptorChain(int paramInt, Request paramRequest, boolean paramBoolean)
{
this.index = paramInt;
this.request = paramRequest;
this.forWebSocket = paramBoolean;
}
public Connection connection()
{
return null;
}
public Response proceed(Request paramRequest)
throws IOException
{
if (this.index < Call.this.client.interceptors().size())
{
Object localObject = new ApplicationInterceptorChain(Call.this, this.index + 1, paramRequest, this.forWebSocket);
paramRequest = (Interceptor)Call.this.client.interceptors().get(this.index);
localObject = paramRequest.intercept((Interceptor.Chain)localObject);
if (localObject == null) {
throw new NullPointerException("application interceptor " + paramRequest + " returned null");
}
return (Response)localObject;
}
return Call.this.getResponse(paramRequest, this.forWebSocket);
}
public Request request()
{
return this.request;
}
}
final class AsyncCall
extends NamedRunnable
{
private final boolean forWebSocket;
private final Callback responseCallback;
private AsyncCall(Callback paramCallback, boolean paramBoolean)
{
super(new Object[] { Call.this.originalRequest.urlString() });
this.responseCallback = paramCallback;
this.forWebSocket = paramBoolean;
}
final void cancel()
{
Call.this.cancel();
}
/* Error */
protected final void execute()
{
// Byte code:
// 0: iconst_1
// 1: istore_1
// 2: aload_0
// 3: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 6: aload_0
// 7: getfield 38 com/squareup/okhttp/Call$AsyncCall:forWebSocket Z
// 10: invokestatic 53 com/squareup/okhttp/Call:access$100 (Lcom/squareup/okhttp/Call;Z)Lcom/squareup/okhttp/Response;
// 13: astore_3
// 14: aload_0
// 15: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 18: getfield 56 com/squareup/okhttp/Call:canceled Z
// 21: istore_2
// 22: iload_2
// 23: ifeq +43 -> 66
// 26: aload_0
// 27: getfield 36 com/squareup/okhttp/Call$AsyncCall:responseCallback Lcom/squareup/okhttp/Callback;
// 30: aload_0
// 31: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 34: getfield 25 com/squareup/okhttp/Call:originalRequest Lcom/squareup/okhttp/Request;
// 37: new 49 java/io/IOException
// 40: dup
// 41: ldc 58
// 43: invokespecial 61 java/io/IOException:<init> (Ljava/lang/String;)V
// 46: invokeinterface 67 3 0
// 51: aload_0
// 52: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 55: invokestatic 71 com/squareup/okhttp/Call:access$300 (Lcom/squareup/okhttp/Call;)Lcom/squareup/okhttp/OkHttpClient;
// 58: invokevirtual 77 com/squareup/okhttp/OkHttpClient:getDispatcher ()Lcom/squareup/okhttp/Dispatcher;
// 61: aload_0
// 62: invokevirtual 83 com/squareup/okhttp/Dispatcher:finished (Lcom/squareup/okhttp/Call$AsyncCall;)V
// 65: return
// 66: aload_0
// 67: getfield 36 com/squareup/okhttp/Call$AsyncCall:responseCallback Lcom/squareup/okhttp/Callback;
// 70: aload_3
// 71: invokeinterface 87 2 0
// 76: goto -25 -> 51
// 79: astore_3
// 80: iload_1
// 81: ifeq +50 -> 131
// 84: getstatic 93 com/squareup/okhttp/internal/Internal:logger Ljava/util/logging/Logger;
// 87: getstatic 99 java/util/logging/Level:INFO Ljava/util/logging/Level;
// 90: new 101 java/lang/StringBuilder
// 93: dup
// 94: ldc 103
// 96: invokespecial 104 java/lang/StringBuilder:<init> (Ljava/lang/String;)V
// 99: aload_0
// 100: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 103: invokestatic 108 com/squareup/okhttp/Call:access$200 (Lcom/squareup/okhttp/Call;)Ljava/lang/String;
// 106: invokevirtual 112 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 109: invokevirtual 115 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 112: aload_3
// 113: invokevirtual 121 java/util/logging/Logger:log (Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
// 116: aload_0
// 117: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 120: invokestatic 71 com/squareup/okhttp/Call:access$300 (Lcom/squareup/okhttp/Call;)Lcom/squareup/okhttp/OkHttpClient;
// 123: invokevirtual 77 com/squareup/okhttp/OkHttpClient:getDispatcher ()Lcom/squareup/okhttp/Dispatcher;
// 126: aload_0
// 127: invokevirtual 83 com/squareup/okhttp/Dispatcher:finished (Lcom/squareup/okhttp/Call$AsyncCall;)V
// 130: return
// 131: aload_0
// 132: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 135: getfield 125 com/squareup/okhttp/Call:engine Lcom/squareup/okhttp/internal/http/HttpEngine;
// 138: ifnonnull +44 -> 182
// 141: aload_0
// 142: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 145: getfield 25 com/squareup/okhttp/Call:originalRequest Lcom/squareup/okhttp/Request;
// 148: astore 4
// 150: aload_0
// 151: getfield 36 com/squareup/okhttp/Call$AsyncCall:responseCallback Lcom/squareup/okhttp/Callback;
// 154: aload 4
// 156: aload_3
// 157: invokeinterface 67 3 0
// 162: goto -46 -> 116
// 165: astore_3
// 166: aload_0
// 167: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 170: invokestatic 71 com/squareup/okhttp/Call:access$300 (Lcom/squareup/okhttp/Call;)Lcom/squareup/okhttp/OkHttpClient;
// 173: invokevirtual 77 com/squareup/okhttp/OkHttpClient:getDispatcher ()Lcom/squareup/okhttp/Dispatcher;
// 176: aload_0
// 177: invokevirtual 83 com/squareup/okhttp/Dispatcher:finished (Lcom/squareup/okhttp/Call$AsyncCall;)V
// 180: aload_3
// 181: athrow
// 182: aload_0
// 183: getfield 17 com/squareup/okhttp/Call$AsyncCall:this$0 Lcom/squareup/okhttp/Call;
// 186: getfield 125 com/squareup/okhttp/Call:engine Lcom/squareup/okhttp/internal/http/HttpEngine;
// 189: invokevirtual 131 com/squareup/okhttp/internal/http/HttpEngine:getRequest ()Lcom/squareup/okhttp/Request;
// 192: astore 4
// 194: goto -44 -> 150
// 197: astore_3
// 198: iconst_0
// 199: istore_1
// 200: goto -120 -> 80
// Local variable table:
// start length slot name signature
// 0 203 0 this AsyncCall
// 1 199 1 i int
// 21 2 2 bool boolean
// 13 58 3 localResponse Response
// 79 78 3 localIOException1 IOException
// 165 16 3 localObject Object
// 197 1 3 localIOException2 IOException
// 148 45 4 localRequest Request
// Exception table:
// from to target type
// 26 51 79 java/io/IOException
// 66 76 79 java/io/IOException
// 2 22 165 finally
// 26 51 165 finally
// 66 76 165 finally
// 84 116 165 finally
// 131 150 165 finally
// 150 162 165 finally
// 182 194 165 finally
// 2 22 197 java/io/IOException
}
final Call get()
{
return Call.this;
}
final String host()
{
return Call.this.originalRequest.httpUrl().host();
}
final Request request()
{
return Call.this.originalRequest;
}
final Object tag()
{
return Call.this.originalRequest.tag();
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/Call.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/