[Kotlin] Allow other content-types when only interested in status-code / Unit (#19801)

* Allow Unit response

* Updating samples

* Improve comment for Unit shortcut
This commit is contained in:
roelwuytens-androme
2024-10-07 14:18:51 +02:00
committed by GitHub
parent 9a0fc5900f
commit 7d1e9997d0
21 changed files with 105 additions and 42 deletions

View File

@@ -126,8 +126,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
val body = response.body
if(body == null) {
return null
}
if (T::class.java == File::class.java) {
} else if (T::class.java == Unit::class.java) {
// No need to parse the body when we're not interested in the body
// Useful when API is returning other Content-Type
return null
} else if (T::class.java == File::class.java) {
// return tempFile
val contentDisposition = response.header("Content-Disposition")