Request.java
7.32 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
package com.squareup.okhttp;
import com.squareup.okhttp.internal.http.HttpMethod;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.List;
public final class Request
{
private final RequestBody body;
private volatile CacheControl cacheControl;
private final Headers headers;
private volatile URI javaNetUri;
private volatile URL javaNetUrl;
private final String method;
private final Object tag;
private final HttpUrl url;
private Request(Builder paramBuilder)
{
this.url = paramBuilder.url;
this.method = paramBuilder.method;
this.headers = paramBuilder.headers.build();
this.body = paramBuilder.body;
if (paramBuilder.tag != null) {}
for (paramBuilder = paramBuilder.tag;; paramBuilder = this)
{
this.tag = paramBuilder;
return;
}
}
public final RequestBody body()
{
return this.body;
}
public final CacheControl cacheControl()
{
CacheControl localCacheControl = this.cacheControl;
if (localCacheControl != null) {
return localCacheControl;
}
localCacheControl = CacheControl.parse(this.headers);
this.cacheControl = localCacheControl;
return localCacheControl;
}
public final String header(String paramString)
{
return this.headers.get(paramString);
}
public final Headers headers()
{
return this.headers;
}
public final List<String> headers(String paramString)
{
return this.headers.values(paramString);
}
public final HttpUrl httpUrl()
{
return this.url;
}
public final boolean isHttps()
{
return this.url.isHttps();
}
public final String method()
{
return this.method;
}
public final Builder newBuilder()
{
return new Builder(this, null);
}
public final Object tag()
{
return this.tag;
}
public final String toString()
{
StringBuilder localStringBuilder = new StringBuilder("Request{method=").append(this.method).append(", url=").append(this.url).append(", tag=");
if (this.tag != this) {}
for (Object localObject = this.tag;; localObject = null) {
return localObject + '}';
}
}
public final URI uri()
throws IOException
{
try
{
URI localURI = this.javaNetUri;
if (localURI != null) {
return localURI;
}
localURI = this.url.uri();
this.javaNetUri = localURI;
return localURI;
}
catch (IllegalStateException localIllegalStateException)
{
throw new IOException(localIllegalStateException.getMessage());
}
}
public final URL url()
{
URL localURL = this.javaNetUrl;
if (localURL != null) {
return localURL;
}
localURL = this.url.url();
this.javaNetUrl = localURL;
return localURL;
}
public final String urlString()
{
return this.url.toString();
}
public static class Builder
{
private RequestBody body;
private Headers.Builder headers;
private String method;
private Object tag;
private HttpUrl url;
public Builder()
{
this.method = "GET";
this.headers = new Headers.Builder();
}
private Builder(Request paramRequest)
{
this.url = paramRequest.url;
this.method = paramRequest.method;
this.body = paramRequest.body;
this.tag = paramRequest.tag;
this.headers = paramRequest.headers.newBuilder();
}
public Builder addHeader(String paramString1, String paramString2)
{
this.headers.add(paramString1, paramString2);
return this;
}
public Request build()
{
if (this.url == null) {
throw new IllegalStateException("url == null");
}
return new Request(this, null);
}
public Builder cacheControl(CacheControl paramCacheControl)
{
paramCacheControl = paramCacheControl.toString();
if (paramCacheControl.isEmpty()) {
return removeHeader("Cache-Control");
}
return header("Cache-Control", paramCacheControl);
}
public Builder delete()
{
return delete(RequestBody.create(null, new byte[0]));
}
public Builder delete(RequestBody paramRequestBody)
{
return method("DELETE", paramRequestBody);
}
public Builder get()
{
return method("GET", null);
}
public Builder head()
{
return method("HEAD", null);
}
public Builder header(String paramString1, String paramString2)
{
this.headers.set(paramString1, paramString2);
return this;
}
public Builder headers(Headers paramHeaders)
{
this.headers = paramHeaders.newBuilder();
return this;
}
public Builder method(String paramString, RequestBody paramRequestBody)
{
if ((paramString == null) || (paramString.length() == 0)) {
throw new IllegalArgumentException("method == null || method.length() == 0");
}
if ((paramRequestBody != null) && (!HttpMethod.permitsRequestBody(paramString))) {
throw new IllegalArgumentException("method " + paramString + " must not have a request body.");
}
if ((paramRequestBody == null) && (HttpMethod.requiresRequestBody(paramString))) {
throw new IllegalArgumentException("method " + paramString + " must have a request body.");
}
this.method = paramString;
this.body = paramRequestBody;
return this;
}
public Builder patch(RequestBody paramRequestBody)
{
return method("PATCH", paramRequestBody);
}
public Builder post(RequestBody paramRequestBody)
{
return method("POST", paramRequestBody);
}
public Builder put(RequestBody paramRequestBody)
{
return method("PUT", paramRequestBody);
}
public Builder removeHeader(String paramString)
{
this.headers.removeAll(paramString);
return this;
}
public Builder tag(Object paramObject)
{
this.tag = paramObject;
return this;
}
public Builder url(HttpUrl paramHttpUrl)
{
if (paramHttpUrl == null) {
throw new IllegalArgumentException("url == null");
}
this.url = paramHttpUrl;
return this;
}
public Builder url(String paramString)
{
if (paramString == null) {
throw new IllegalArgumentException("url == null");
}
String str;
if (paramString.regionMatches(true, 0, "ws:", 0, 3)) {
str = "http:" + paramString.substring(3);
}
for (;;)
{
paramString = HttpUrl.parse(str);
if (paramString != null) {
break;
}
throw new IllegalArgumentException("unexpected url: " + str);
str = paramString;
if (paramString.regionMatches(true, 0, "wss:", 0, 4)) {
str = "https:" + paramString.substring(4);
}
}
return url(paramString);
}
public Builder url(URL paramURL)
{
if (paramURL == null) {
throw new IllegalArgumentException("url == null");
}
HttpUrl localHttpUrl = HttpUrl.get(paramURL);
if (localHttpUrl == null) {
throw new IllegalArgumentException("unexpected url: " + paramURL);
}
return url(localHttpUrl);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/Request.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/