use of okio.GzipSink in project zipkin by openzipkin.
the class ZipkinRuleTest method gzippedSpans.
@Test
public void gzippedSpans() throws IOException {
byte[] spansInJson = Codec.JSON.writeSpans(TRACE);
Buffer sink = new Buffer();
GzipSink gzipSink = new GzipSink(sink);
gzipSink.write(new Buffer().write(spansInJson), spansInJson.length);
gzipSink.close();
ByteString gzippedJson = sink.readByteString();
client.newCall(new Request.Builder().url(zipkin.httpUrl() + "/api/v1/spans").addHeader("Content-Encoding", "gzip").post(RequestBody.create(MediaType.parse("application/json"), gzippedJson)).build()).execute();
assertThat(zipkin.getTraces()).containsOnly(TRACE);
assertThat(zipkin.collectorMetrics().bytes()).isEqualTo(spansInJson.length);
}
use of okio.GzipSink in project okhttp by square.
the class OkApacheClientTest method gzip.
private static Buffer gzip(String body) throws IOException {
Buffer buffer = new Buffer();
Okio.buffer(new GzipSink(buffer)).writeUtf8(body).close();
return buffer;
}
use of okio.GzipSink in project okhttp by square.
the class ResponseCacheTest 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 HttpOverHttp2Test method gzip.
public Buffer gzip(String bytes) throws IOException {
Buffer bytesOut = new Buffer();
BufferedSink sink = Okio.buffer(new GzipSink(bytesOut));
sink.writeUtf8(bytes);
sink.close();
return bytesOut;
}
use of okio.GzipSink in project okhttp by square.
the class Http2Test method gzip.
private static Buffer gzip(byte[] data) throws IOException {
Buffer buffer = new Buffer();
Okio.buffer(new GzipSink(buffer)).write(data).close();
return buffer;
}
Aggregations