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

com.jdroid.java.http.okhttp.ReadResponseCommand.kt Maven / Gradle / Ivy

The newest version!
package com.jdroid.java.http.okhttp

import com.jdroid.java.http.HttpService
import okhttp3.Response
import java.io.IOException
import java.io.InputStream
import java.util.zip.GZIPInputStream

class ReadResponseCommand : OkHttpCommand() {

    @Throws(IOException::class)
    override fun doExecute(response: Response): InputStream? {
        var inputStream: InputStream? = null
        if (response.code != 204) {
            inputStream = response.body!!.byteStream()
            val contentEncoding = response.header(HttpService.CONTENT_ENCODING_HEADER)
            if (inputStream != null && contentEncoding != null && contentEncoding.equals(
                    HttpService.GZIP_ENCODING,
                    ignoreCase = true
                )
            ) {
                inputStream = GZIPInputStream(inputStream)
            }
        }
        return inputStream
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy