CacheControl.java
10.8 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
package com.squareup.okhttp;
import com.squareup.okhttp.internal.http.HeaderParser;
import java.util.concurrent.TimeUnit;
public final class CacheControl
{
public static final CacheControl FORCE_CACHE = new Builder().onlyIfCached().maxStale(Integer.MAX_VALUE, TimeUnit.SECONDS).build();
public static final CacheControl FORCE_NETWORK = new Builder().noCache().build();
String headerValue;
private final boolean isPrivate;
private final boolean isPublic;
private final int maxAgeSeconds;
private final int maxStaleSeconds;
private final int minFreshSeconds;
private final boolean mustRevalidate;
private final boolean noCache;
private final boolean noStore;
private final boolean noTransform;
private final boolean onlyIfCached;
private final int sMaxAgeSeconds;
private CacheControl(Builder paramBuilder)
{
this.noCache = paramBuilder.noCache;
this.noStore = paramBuilder.noStore;
this.maxAgeSeconds = paramBuilder.maxAgeSeconds;
this.sMaxAgeSeconds = -1;
this.isPrivate = false;
this.isPublic = false;
this.mustRevalidate = false;
this.maxStaleSeconds = paramBuilder.maxStaleSeconds;
this.minFreshSeconds = paramBuilder.minFreshSeconds;
this.onlyIfCached = paramBuilder.onlyIfCached;
this.noTransform = paramBuilder.noTransform;
}
private CacheControl(boolean paramBoolean1, boolean paramBoolean2, int paramInt1, int paramInt2, boolean paramBoolean3, boolean paramBoolean4, boolean paramBoolean5, int paramInt3, int paramInt4, boolean paramBoolean6, boolean paramBoolean7, String paramString)
{
this.noCache = paramBoolean1;
this.noStore = paramBoolean2;
this.maxAgeSeconds = paramInt1;
this.sMaxAgeSeconds = paramInt2;
this.isPrivate = paramBoolean3;
this.isPublic = paramBoolean4;
this.mustRevalidate = paramBoolean5;
this.maxStaleSeconds = paramInt3;
this.minFreshSeconds = paramInt4;
this.onlyIfCached = paramBoolean6;
this.noTransform = paramBoolean7;
this.headerValue = paramString;
}
private String headerValue()
{
StringBuilder localStringBuilder = new StringBuilder();
if (this.noCache) {
localStringBuilder.append("no-cache, ");
}
if (this.noStore) {
localStringBuilder.append("no-store, ");
}
if (this.maxAgeSeconds != -1) {
localStringBuilder.append("max-age=").append(this.maxAgeSeconds).append(", ");
}
if (this.sMaxAgeSeconds != -1) {
localStringBuilder.append("s-maxage=").append(this.sMaxAgeSeconds).append(", ");
}
if (this.isPrivate) {
localStringBuilder.append("private, ");
}
if (this.isPublic) {
localStringBuilder.append("public, ");
}
if (this.mustRevalidate) {
localStringBuilder.append("must-revalidate, ");
}
if (this.maxStaleSeconds != -1) {
localStringBuilder.append("max-stale=").append(this.maxStaleSeconds).append(", ");
}
if (this.minFreshSeconds != -1) {
localStringBuilder.append("min-fresh=").append(this.minFreshSeconds).append(", ");
}
if (this.onlyIfCached) {
localStringBuilder.append("only-if-cached, ");
}
if (this.noTransform) {
localStringBuilder.append("no-transform, ");
}
if (localStringBuilder.length() == 0) {
return "";
}
localStringBuilder.delete(localStringBuilder.length() - 2, localStringBuilder.length());
return localStringBuilder.toString();
}
public static CacheControl parse(Headers paramHeaders)
{
boolean bool5 = false;
int i1 = -1;
int n = -1;
boolean bool7 = false;
boolean bool6 = false;
boolean bool4 = false;
int m = -1;
int k = -1;
boolean bool3 = false;
boolean bool2 = false;
int i = 1;
int i8 = paramHeaders.size();
int i2 = 0;
Object localObject1 = null;
boolean bool1 = false;
while (i2 < i8)
{
Object localObject2 = paramHeaders.name(i2);
String str1 = paramHeaders.value(i2);
int i3;
if (((String)localObject2).equalsIgnoreCase("Cache-Control")) {
if (localObject1 != null)
{
i = 0;
i3 = 0;
}
}
for (;;)
{
label89:
localObject2 = localObject1;
bool14 = bool5;
i7 = i1;
i6 = n;
bool13 = bool7;
bool12 = bool6;
bool11 = bool4;
i5 = m;
i4 = k;
bool10 = bool3;
bool9 = bool2;
j = i;
bool8 = bool1;
if (i3 >= str1.length()) {
break label603;
}
j = HeaderParser.skipUntil(str1, i3, "=,;");
String str2 = str1.substring(i3, j).trim();
if ((j == str1.length()) || (str1.charAt(j) == ',') || (str1.charAt(j) == ';'))
{
j += 1;
localObject2 = null;
}
for (;;)
{
if (!"no-cache".equalsIgnoreCase(str2)) {
break label341;
}
bool1 = true;
i3 = j;
break label89;
localObject1 = str1;
break;
if (!((String)localObject2).equalsIgnoreCase("Pragma")) {
break label554;
}
i = 0;
break;
i3 = HeaderParser.skipWhitespace(str1, j + 1);
if ((i3 < str1.length()) && (str1.charAt(i3) == '"'))
{
j = i3 + 1;
i3 = HeaderParser.skipUntil(str1, j, "\"");
localObject2 = str1.substring(j, i3);
j = i3 + 1;
}
else
{
j = HeaderParser.skipUntil(str1, i3, ",;");
localObject2 = str1.substring(i3, j).trim();
}
}
label341:
if ("no-store".equalsIgnoreCase(str2))
{
bool5 = true;
i3 = j;
}
else if ("max-age".equalsIgnoreCase(str2))
{
i1 = HeaderParser.parseSeconds((String)localObject2, -1);
i3 = j;
}
else if ("s-maxage".equalsIgnoreCase(str2))
{
n = HeaderParser.parseSeconds((String)localObject2, -1);
i3 = j;
}
else if ("private".equalsIgnoreCase(str2))
{
bool7 = true;
i3 = j;
}
else if ("public".equalsIgnoreCase(str2))
{
bool6 = true;
i3 = j;
}
else if ("must-revalidate".equalsIgnoreCase(str2))
{
bool4 = true;
i3 = j;
}
else if ("max-stale".equalsIgnoreCase(str2))
{
m = HeaderParser.parseSeconds((String)localObject2, Integer.MAX_VALUE);
i3 = j;
}
else if ("min-fresh".equalsIgnoreCase(str2))
{
k = HeaderParser.parseSeconds((String)localObject2, -1);
i3 = j;
}
else if ("only-if-cached".equalsIgnoreCase(str2))
{
bool3 = true;
i3 = j;
}
else
{
i3 = j;
if ("no-transform".equalsIgnoreCase(str2))
{
bool2 = true;
i3 = j;
}
}
}
label554:
boolean bool8 = bool1;
int j = i;
boolean bool9 = bool2;
boolean bool10 = bool3;
int i4 = k;
int i5 = m;
boolean bool11 = bool4;
boolean bool12 = bool6;
boolean bool13 = bool7;
int i6 = n;
int i7 = i1;
boolean bool14 = bool5;
localObject2 = localObject1;
label603:
i2 += 1;
bool1 = bool8;
localObject1 = localObject2;
bool5 = bool14;
i1 = i7;
n = i6;
bool7 = bool13;
bool6 = bool12;
bool4 = bool11;
m = i5;
k = i4;
bool3 = bool10;
bool2 = bool9;
i = j;
}
if (i == 0) {}
for (paramHeaders = null;; paramHeaders = (Headers)localObject1) {
return new CacheControl(bool1, bool5, i1, n, bool7, bool6, bool4, m, k, bool3, bool2, paramHeaders);
}
}
public final boolean isPrivate()
{
return this.isPrivate;
}
public final boolean isPublic()
{
return this.isPublic;
}
public final int maxAgeSeconds()
{
return this.maxAgeSeconds;
}
public final int maxStaleSeconds()
{
return this.maxStaleSeconds;
}
public final int minFreshSeconds()
{
return this.minFreshSeconds;
}
public final boolean mustRevalidate()
{
return this.mustRevalidate;
}
public final boolean noCache()
{
return this.noCache;
}
public final boolean noStore()
{
return this.noStore;
}
public final boolean noTransform()
{
return this.noTransform;
}
public final boolean onlyIfCached()
{
return this.onlyIfCached;
}
public final int sMaxAgeSeconds()
{
return this.sMaxAgeSeconds;
}
public final String toString()
{
String str = this.headerValue;
if (str != null) {
return str;
}
str = headerValue();
this.headerValue = str;
return str;
}
public static final class Builder
{
int maxAgeSeconds = -1;
int maxStaleSeconds = -1;
int minFreshSeconds = -1;
boolean noCache;
boolean noStore;
boolean noTransform;
boolean onlyIfCached;
public final CacheControl build()
{
return new CacheControl(this, null);
}
public final Builder maxAge(int paramInt, TimeUnit paramTimeUnit)
{
if (paramInt < 0) {
throw new IllegalArgumentException("maxAge < 0: " + paramInt);
}
long l = paramTimeUnit.toSeconds(paramInt);
if (l > 2147483647L) {}
for (paramInt = Integer.MAX_VALUE;; paramInt = (int)l)
{
this.maxAgeSeconds = paramInt;
return this;
}
}
public final Builder maxStale(int paramInt, TimeUnit paramTimeUnit)
{
if (paramInt < 0) {
throw new IllegalArgumentException("maxStale < 0: " + paramInt);
}
long l = paramTimeUnit.toSeconds(paramInt);
if (l > 2147483647L) {}
for (paramInt = Integer.MAX_VALUE;; paramInt = (int)l)
{
this.maxStaleSeconds = paramInt;
return this;
}
}
public final Builder minFresh(int paramInt, TimeUnit paramTimeUnit)
{
if (paramInt < 0) {
throw new IllegalArgumentException("minFresh < 0: " + paramInt);
}
long l = paramTimeUnit.toSeconds(paramInt);
if (l > 2147483647L) {}
for (paramInt = Integer.MAX_VALUE;; paramInt = (int)l)
{
this.minFreshSeconds = paramInt;
return this;
}
}
public final Builder noCache()
{
this.noCache = true;
return this;
}
public final Builder noStore()
{
this.noStore = true;
return this;
}
public final Builder noTransform()
{
this.noTransform = true;
return this;
}
public final Builder onlyIfCached()
{
this.onlyIfCached = true;
return this;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/CacheControl.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/