Add missing ClientResponse Coroutines extensions

This commit adds awaitBodilessEntity() and
createExceptionAndAwait() missing ClientResponse
Coroutines extensions.

Closes gh-25866
This commit is contained in:
Sébastien Deleuze
2020-10-07 10:55:18 +02:00
parent b2d8180f82
commit e899397438
2 changed files with 40 additions and 0 deletions

View File

@@ -164,3 +164,23 @@ suspend inline fun <reified T : Any> ClientResponse.awaitEntityList(): ResponseE
*/
suspend fun <T : Any> ClientResponse.awaitEntityList(clazz: KClass<T>): ResponseEntity<List<T>> =
toEntityList(clazz.java).awaitSingle()
/**
* Coroutines variant of [ClientResponse.toBodilessEntity].
*
* @author Sebastien Deleuze
* @since 5.3
*/
suspend fun ClientResponse.awaitBodilessEntity(): ResponseEntity<Void> =
toBodilessEntity().awaitSingle()
/**
* Coroutines variant of [ClientResponse.createException].
*
* @author Sebastien Deleuze
* @since 5.3
*/
suspend fun ClientResponse.createExceptionAndAwait(): WebClientResponseException =
createException().awaitSingle()