INNER CODE UNIT · Kotlin
HttpUrlFetcher
kittinunf/fuel · fuel/src/appleMain/kotlin/fuel/HttpUrlFetcher.kt:23
internal class HttpUrlFetcher(
private val sessionConfiguration: NSURLSessionConfiguration,
) {
@OptIn(BetaInteropApi::class)
suspend fun fetch(
method: String,
request: Request,
): HttpResponse =
suspendCancellableCoroutine { continuation ->
val url =
request.parameters?.let {
request.url.fillURLWithParameters(it)
} ?: request.url
val mutableURLRequest =
NSMutableURLRequest.requestWithURL(NSURL(string = url)).apply {
request.body?.let {
setHTTPBody(it.encode())