RequestBody.java
3.58 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
package com.squareup.okhttp;
import com.squareup.okhttp.internal.Util;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import okio.BufferedSink;
import okio.ByteString;
import okio.Okio;
import okio.Source;
public abstract class RequestBody
{
public static RequestBody create(MediaType paramMediaType, final File paramFile)
{
if (paramFile == null) {
throw new NullPointerException("content == null");
}
new RequestBody()
{
public final long contentLength()
{
return paramFile.length();
}
public final MediaType contentType()
{
return this.val$contentType;
}
public final void writeTo(BufferedSink paramAnonymousBufferedSink)
throws IOException
{
Object localObject = null;
try
{
Source localSource = Okio.source(paramFile);
localObject = localSource;
paramAnonymousBufferedSink.writeAll(localSource);
Util.closeQuietly(localSource);
return;
}
finally
{
Util.closeQuietly((Closeable)localObject);
}
}
};
}
public static RequestBody create(MediaType paramMediaType, String paramString)
{
Object localObject = Util.UTF_8;
MediaType localMediaType = paramMediaType;
if (paramMediaType != null)
{
Charset localCharset = paramMediaType.charset();
localObject = localCharset;
localMediaType = paramMediaType;
if (localCharset == null)
{
localObject = Util.UTF_8;
localMediaType = MediaType.parse(paramMediaType + "; charset=utf-8");
}
}
return create(localMediaType, paramString.getBytes((Charset)localObject));
}
public static RequestBody create(MediaType paramMediaType, final ByteString paramByteString)
{
new RequestBody()
{
public final long contentLength()
throws IOException
{
return paramByteString.size();
}
public final MediaType contentType()
{
return this.val$contentType;
}
public final void writeTo(BufferedSink paramAnonymousBufferedSink)
throws IOException
{
paramAnonymousBufferedSink.write(paramByteString);
}
};
}
public static RequestBody create(MediaType paramMediaType, byte[] paramArrayOfByte)
{
return create(paramMediaType, paramArrayOfByte, 0, paramArrayOfByte.length);
}
public static RequestBody create(MediaType paramMediaType, final byte[] paramArrayOfByte, final int paramInt1, final int paramInt2)
{
if (paramArrayOfByte == null) {
throw new NullPointerException("content == null");
}
Util.checkOffsetAndCount(paramArrayOfByte.length, paramInt1, paramInt2);
new RequestBody()
{
public final long contentLength()
{
return paramInt2;
}
public final MediaType contentType()
{
return this.val$contentType;
}
public final void writeTo(BufferedSink paramAnonymousBufferedSink)
throws IOException
{
paramAnonymousBufferedSink.write(paramArrayOfByte, paramInt1, paramInt2);
}
};
}
public long contentLength()
throws IOException
{
return -1L;
}
public abstract MediaType contentType();
public abstract void writeTo(BufferedSink paramBufferedSink)
throws IOException;
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/RequestBody.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/