kohttp / io.github.rybalkinsd.kohttp.ext / okhttp3.Response / eager

eager

fun Response.eager(): EagerResponse

This feature is EXPERIMENTAL, API could be changed in the future releases.

In many cases response body is simple and it could be treated as String

Without eager() the correct way to consume response body is val response = httpGet { }

    response.use {
        it.body().string()
    }

However with eager() method it is possible to consume easier and get a EagerResponse instance val response = httpGet { }.eager()

This method loads entire response body into memory. If the response body is very large this may trigger an {@link OutOfMemoryError}. Prefer to stream the response body if this is a possibility for your response.

Since
0.3.0

Author
sergey