in src/main/java/com/spotify/ffwd/http/GzipRequestInterceptor.java [55:78]
private RequestBody compress(final RequestBody body) throws IOException {
final Buffer buffer = new Buffer();
try (final BufferedSink gzipSink = Okio.buffer(new GzipSink(buffer))) {
body.writeTo(gzipSink);
}
return new RequestBody() {
@Override
public MediaType contentType() {
return body.contentType();
}
@Override
public long contentLength() {
return buffer.size();
}
@Override
public void writeTo(BufferedSink sink) throws IOException {
sink.write(buffer.snapshot());
}
};
}