com.jdroid.java.http.okhttp.ReadResponseCommand.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdroid-java-http-okhttp Show documentation
Show all versions of jdroid-java-http-okhttp Show documentation
OKHttp Http Layer Implementation for Jdroid
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