ResponseBody.java
3.55 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
package com.squareup.okhttp;
import com.squareup.okhttp.internal.Util;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import okio.Buffer;
import okio.BufferedSource;
public abstract class ResponseBody
implements Closeable
{
private Reader reader;
private Charset charset()
{
MediaType localMediaType = contentType();
if (localMediaType != null) {
return localMediaType.charset(Util.UTF_8);
}
return Util.UTF_8;
}
public static ResponseBody create(MediaType paramMediaType, final long paramLong, BufferedSource paramBufferedSource)
{
if (paramBufferedSource == null) {
throw new NullPointerException("source == null");
}
new ResponseBody()
{
public final long contentLength()
{
return paramLong;
}
public final MediaType contentType()
{
return this.val$contentType;
}
public final BufferedSource source()
{
return this.val$content;
}
};
}
public static ResponseBody 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");
}
}
paramMediaType = new Buffer().writeString(paramString, (Charset)localObject);
return create(localMediaType, paramMediaType.size(), paramMediaType);
}
public static ResponseBody create(MediaType paramMediaType, byte[] paramArrayOfByte)
{
Buffer localBuffer = new Buffer().write(paramArrayOfByte);
return create(paramMediaType, paramArrayOfByte.length, localBuffer);
}
public final InputStream byteStream()
throws IOException
{
return source().inputStream();
}
public final byte[] bytes()
throws IOException
{
long l = contentLength();
if (l > 2147483647L) {
throw new IOException("Cannot buffer entire body for content length: " + l);
}
BufferedSource localBufferedSource = source();
try
{
byte[] arrayOfByte1 = localBufferedSource.readByteArray();
Util.closeQuietly(localBufferedSource);
if ((l != -1L) && (l != arrayOfByte1.length)) {
throw new IOException("Content-Length and stream length disagree");
}
}
finally
{
Util.closeQuietly(localBufferedSource);
}
return arrayOfByte2;
}
public final Reader charStream()
throws IOException
{
Object localObject = this.reader;
if (localObject != null) {
return (Reader)localObject;
}
localObject = new InputStreamReader(byteStream(), charset());
this.reader = ((Reader)localObject);
return (Reader)localObject;
}
public void close()
throws IOException
{
source().close();
}
public abstract long contentLength()
throws IOException;
public abstract MediaType contentType();
public abstract BufferedSource source()
throws IOException;
public final String string()
throws IOException
{
return new String(bytes(), charset().name());
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/ResponseBody.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/