All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eg.agent.android.instrumentation.okhttp3.PrebufferedResponseBody Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package com.eg.agent.android.instrumentation.okhttp3;

import okhttp3.MediaType;
import okhttp3.ResponseBody;
import okio.BufferedSource;

public class PrebufferedResponseBody extends ResponseBody {
    private final long contentLength;
    private final MediaType contentType;
    private final ResponseBody impl;
    private final BufferedSource source;

    public PrebufferedResponseBody(ResponseBody impl, BufferedSource source) {
        this.impl = impl;
        this.source = source;
        this.contentType = impl.contentType();
        this.contentLength = impl.contentLength() >= 0 ? impl.contentLength() : source.buffer().size();
    }

    public MediaType contentType() {
        return this.impl.contentType();
    }

    public long contentLength() {
        return this.contentLength;
    }

    public BufferedSource source() {
        return this.source;
    }

    public void close() {
        this.impl.close();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy