diff --git a/.codecov.yaml b/.codecov.yaml index 111734bb..3a33d841 100644 --- a/.codecov.yaml +++ b/.codecov.yaml @@ -1,4 +1,7 @@ status: project: default: - target: 90 \ No newline at end of file + target: 90 + patch: + default: + enabled: no \ No newline at end of file diff --git a/kohttp/src/main/kotlin/io/github/rybalkinsd/kohttp/ext/ResponseExt.kt b/kohttp/src/main/kotlin/io/github/rybalkinsd/kohttp/ext/ResponseExt.kt index 1817750c..176c8757 100644 --- a/kohttp/src/main/kotlin/io/github/rybalkinsd/kohttp/ext/ResponseExt.kt +++ b/kohttp/src/main/kotlin/io/github/rybalkinsd/kohttp/ext/ResponseExt.kt @@ -1,22 +1,29 @@ package io.github.rybalkinsd.kohttp.ext import okhttp3.Response - +import java.io.InputStream /** * Returns Response Body as String. * * @return Response body as a `String?`. + *
+ * Note: This function will close `ResponseBody` + *
* @since 0.9.0 - * @author gokul + * @author gokul, sergey */ -fun Response.asString() = body()?.string() +fun Response.asString(): String? = body()?.use { it.string() } /** - * Returns Response Body as a Stream. + * Returns Response Body as a Stream. + * * * @return Response body as a `InputStream?`. + *+ * Note: Response stream must be closed after use + *
* @since 0.9.0 * @author gokul */ -fun Response.asStream() = body()?.byteStream() +fun Response.asStream(): InputStream? = body()?.byteStream()