Search in sources :

Example 21 with GzipSink

use of okio.GzipSink in project xDrip-plus by jamorham.

the class GzipRequestInterceptor method gzip.

private RequestBody gzip(final RequestBody body) {
    return new RequestBody() {

        @Override
        public MediaType contentType() {
            return body.contentType();
        }

        @Override
        public long contentLength() {
            // We don't know the compressed length in advance!
            return -1;
        }

        @Override
        public void writeTo(BufferedSink sink) throws IOException {
            BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
            body.writeTo(gzipSink);
            gzipSink.close();
        }
    };
}
Also used : GzipSink(okio.GzipSink) BufferedSink(okio.BufferedSink) RequestBody(com.squareup.okhttp.RequestBody)

Example 22 with GzipSink

use of okio.GzipSink in project graphhopper by graphhopper.

the class GzipRequestInterceptor method gzip.

private RequestBody gzip(final RequestBody body) {
    return new RequestBody() {

        @Override
        public MediaType contentType() {
            return body.contentType();
        }

        @Override
        public long contentLength() {
            // We don't know the compressed length in advance!
            return -1;
        }

        @Override
        public void writeTo(BufferedSink sink) throws IOException {
            BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
            body.writeTo(gzipSink);
            gzipSink.close();
        }
    };
}
Also used : GzipSink(okio.GzipSink) BufferedSink(okio.BufferedSink)

Example 23 with GzipSink

use of okio.GzipSink in project java by kubernetes-client.

the class GzipRequestInterceptor method gzip.

private RequestBody gzip(final RequestBody body) {
    return new RequestBody() {

        @Override
        public MediaType contentType() {
            return body.contentType();
        }

        @Override
        public long contentLength() {
            // We don't know the compressed length in advance!
            return -1;
        }

        @Override
        public void writeTo(BufferedSink sink) throws IOException {
            BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
            body.writeTo(gzipSink);
            gzipSink.close();
        }
    };
}
Also used : GzipSink(okio.GzipSink) BufferedSink(okio.BufferedSink)

Example 24 with GzipSink

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;
}
Also used : Buffer(okio.Buffer) GzipSink(okio.GzipSink) BufferedSink(okio.BufferedSink)

Example 25 with GzipSink

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;
}
Also used : Buffer(okio.Buffer) GzipSink(okio.GzipSink) BufferedSink(okio.BufferedSink)

Aggregations

GzipSink (okio.GzipSink)26 BufferedSink (okio.BufferedSink)20 Buffer (okio.Buffer)13 RequestBody (okhttp3.RequestBody)5 ByteString (okio.ByteString)3 RequestBody (com.squareup.okhttp.RequestBody)2 Request (okhttp3.Request)2 Response (okhttp3.Response)2 Test (org.junit.Test)2 ErrorPayload (co.elastic.apm.impl.error.ErrorPayload)1 File (java.io.File)1 IOException (java.io.IOException)1 TreeSet (java.util.TreeSet)1 OkHttpClient (okhttp3.OkHttpClient)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 BufferedSource (okio.BufferedSource)1 Sink (okio.Sink)1