kohttp / io.github.rybalkinsd.kohttp.ext / kotlin.String / httpGetAsync

httpGetAsync

fun String.httpGetAsync(client: Factory = defaultHttpClient): Deferred<Response>

Async version of http GET request with the provided String url. this function runs a new coroutine with Unconfined CoroutineDispatcher.

Parameters

client - gives a possibility to provide your implementation of HttpClient defaultHttpClient by default

Return

a Response instance Do not forget to close response even if you do not use it.

Instances of this class are not immutable: the response body is a one-shot value that may be consumed only once and then closed. All other properties are immutable.

Usage example: val response = "http://host:port/path/?a=b".httpGetAsync() ... response.await().use { your code here }

Since
0.1.0

Author
sergey