RetryableSink.java
1.89 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
package com.squareup.okhttp.internal.http;
import com.squareup.okhttp.internal.Util;
import java.io.IOException;
import java.net.ProtocolException;
import okio.Buffer;
import okio.Sink;
import okio.Timeout;
public final class RetryableSink
implements Sink
{
private boolean closed;
private final Buffer content = new Buffer();
private final int limit;
public RetryableSink()
{
this(-1);
}
public RetryableSink(int paramInt)
{
this.limit = paramInt;
}
public final void close()
throws IOException
{
if (this.closed) {}
do
{
return;
this.closed = true;
} while (this.content.size() >= this.limit);
throw new ProtocolException("content-length promised " + this.limit + " bytes, but received " + this.content.size());
}
public final long contentLength()
throws IOException
{
return this.content.size();
}
public final void flush()
throws IOException
{}
public final Timeout timeout()
{
return Timeout.NONE;
}
public final void write(Buffer paramBuffer, long paramLong)
throws IOException
{
if (this.closed) {
throw new IllegalStateException("closed");
}
Util.checkOffsetAndCount(paramBuffer.size(), 0L, paramLong);
if ((this.limit != -1) && (this.content.size() > this.limit - paramLong)) {
throw new ProtocolException("exceeded content-length limit of " + this.limit + " bytes");
}
this.content.write(paramBuffer, paramLong);
}
public final void writeToSocket(Sink paramSink)
throws IOException
{
Buffer localBuffer = new Buffer();
this.content.copyTo(localBuffer, 0L, this.content.size());
paramSink.write(localBuffer, localBuffer.size());
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/internal/http/RetryableSink.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/