Skip to content

Commit

Permalink
Merge pull request square#1205 from square/jw/one-one-oh
Browse files Browse the repository at this point in the history
Update to Okio 1.1.0.
  • Loading branch information
swankjesse committed Dec 16, 2014
2 parents 6686452 + 117ebac commit 24aa4e8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ private RequestBody uppercase(final RequestBody original) {
Sink uppercase = uppercase(sink);
BufferedSink bufferedSink = Okio.buffer(uppercase);
original.writeTo(bufferedSink);

// TODO: add BufferedSink.emit() to drain its buffer into its sink (without flush).
uppercase.write(bufferedSink.buffer(), bufferedSink.buffer().size());
bufferedSink.emit();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ private void writeHex(long i) throws IOException {

private class AbstractSource {
private final CacheRequest cacheRequest;
protected final Sink cacheBody;
protected final BufferedSink cacheBody;
protected boolean closed;

AbstractSource(CacheRequest cacheRequest) throws IOException {
Expand All @@ -381,17 +381,15 @@ private class AbstractSource {
cacheRequest = null;
}

this.cacheBody = cacheBody;
this.cacheBody = cacheBody != null ? Okio.buffer(cacheBody) : null;
this.cacheRequest = cacheRequest;
}

/** Copy the last {@code byteCount} bytes of {@code source} to the cache body. */
protected final void cacheWrite(Buffer source, long byteCount) throws IOException {
if (cacheBody != null) {
// TODO source.copyTo(cacheBody, source.size() - byteCount, byteCount)
Buffer sourceCopy = source.clone();
sourceCopy.skip(sourceCopy.size() - byteCount);
cacheBody.write(sourceCopy, byteCount);
source.copyTo(cacheBody.buffer(), source.size() - byteCount, byteCount);
cacheBody.emitCompleteSegments();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;
import okio.Buffer;
import okio.BufferedSink;
import okio.ByteString;
import okio.Okio;
import okio.Sink;
import okio.Source;
import okio.Timeout;
Expand Down Expand Up @@ -241,7 +243,7 @@ private static class SpdySource implements Source {
private final SpdyStream stream;
private final Source source;
private final CacheRequest cacheRequest;
private final Sink cacheBody;
private final BufferedSink cacheBody;

private boolean inputExhausted;
private boolean closed;
Expand All @@ -256,7 +258,7 @@ private static class SpdySource implements Source {
cacheRequest = null;
}

this.cacheBody = cacheBody;
this.cacheBody = cacheBody != null ? Okio.buffer(cacheBody) : null;
this.cacheRequest = cacheRequest;
}

Expand All @@ -276,8 +278,8 @@ private static class SpdySource implements Source {
}

if (cacheBody != null) {
// TODO get buffer.copyTo(cacheBody, read);
cacheBody.write(buffer.clone(), read);
buffer.copyTo(cacheBody.buffer(), buffer.size() - read, read);
cacheBody.emitCompleteSegments();
}

return read;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<!-- Compilation -->
<java.version>1.7</java.version>
<okio.version>1.0.1</okio.version>
<okio.version>1.1.0</okio.version>
<!-- Targetted to jdk7u60-b13; Oracle jdk7u55-b13. -->
<npn.version>1.1.7.v20140316</npn.version>
<!-- Targetted to OpenJDK 8 b132 -->
Expand Down

0 comments on commit 24aa4e8

Please sign in to comment.