use of okio.GzipSink in project zipkin by openzipkin.
the class ZipkinServerIntegrationTest method writeSpans_gzipEncoded.
public void writeSpans_gzipEncoded() throws Exception {
byte[] body = Codec.JSON.writeSpans(TRACE);
Buffer sink = new Buffer();
GzipSink gzipSink = new GzipSink(sink);
gzipSink.write(new Buffer().write(body), body.length);
gzipSink.close();
byte[] gzippedBody = sink.readByteArray();
mockMvc.perform(post("/api/v1/spans").content(gzippedBody).header("Content-Encoding", "gzip")).andExpect(status().isAccepted());
}
use of okio.GzipSink in project okhttp by square.
the class Benchmark method newResponse.
private MockResponse newResponse() throws IOException {
byte[] bytes = new byte[bodyByteCount];
random.nextBytes(bytes);
Buffer body = new Buffer().write(bytes);
MockResponse result = new MockResponse();
if (gzip) {
Buffer gzipBody = new Buffer();
GzipSink gzipSink = new GzipSink(gzipBody);
gzipSink.write(body, body.size());
gzipSink.close();
body = gzipBody;
result.addHeader("Content-Encoding: gzip");
}
if (chunked) {
result.setChunkedBody(body, 1024);
} else {
result.setBody(body);
}
for (int i = 0; i < headerCount; i++) {
result.addHeader(randomString(12), randomString(20));
}
return result;
}
use of okio.GzipSink in project okhttp by square.
the class CacheTest method gzip.
/** Returns a gzipped copy of {@code bytes}. */
public Buffer gzip(String data) throws IOException {
Buffer result = new Buffer();
BufferedSink sink = Okio.buffer(new GzipSink(result));
sink.writeUtf8(data);
sink.close();
return result;
}
use of okio.GzipSink in project okhttp by square.
the class InterceptorTest method gzip.
private Buffer gzip(String data) throws IOException {
Buffer result = new Buffer();
BufferedSink sink = Okio.buffer(new GzipSink(result));
sink.writeUtf8(data);
sink.close();
return result;
}
Aggregations