1
0
mirror of https://github.com/square/okhttp.git synced 2025-07-29 17:41:17 +03:00

Reformat with Spotless (#8180)

* Enable spotless

* Run spotlessApply

* Fixup trimMargin

* Re-run spotlessApply
This commit is contained in:
Jesse Wilson
2024-01-07 20:13:22 -05:00
committed by GitHub
parent 0e312d7804
commit a228fd64cc
442 changed files with 24992 additions and 18542 deletions

View File

@ -17,23 +17,32 @@
package okhttp3
import kotlin.coroutines.resumeWithException
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.suspendCancellableCoroutine
import okio.IOException
import kotlin.coroutines.resumeWithException
@OptIn(ExperimentalCoroutinesApi::class)
suspend fun Call.executeAsync(): Response = suspendCancellableCoroutine { continuation ->
continuation.invokeOnCancellation {
this.cancel()
}
this.enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
continuation.resumeWithException(e)
suspend fun Call.executeAsync(): Response =
suspendCancellableCoroutine { continuation ->
continuation.invokeOnCancellation {
this.cancel()
}
this.enqueue(
object : Callback {
override fun onFailure(
call: Call,
e: IOException,
) {
continuation.resumeWithException(e)
}
override fun onResponse(call: Call, response: Response) {
continuation.resume(value = response, onCancellation = { call.cancel() })
}
})
}
override fun onResponse(
call: Call,
response: Response,
) {
continuation.resume(value = response, onCancellation = { call.cancel() })
}
},
)
}

View File

@ -80,7 +80,7 @@ class SuspendCallTest {
MockResponse.Builder()
.bodyDelay(5, TimeUnit.SECONDS)
.body("abc")
.build()
.build(),
)
val call = client.newCall(request)
@ -109,7 +109,7 @@ class SuspendCallTest {
MockResponse.Builder()
.bodyDelay(5, TimeUnit.SECONDS)
.body("abc")
.build()
.build(),
)
val call = client.newCall(request)
@ -137,7 +137,7 @@ class SuspendCallTest {
MockResponse(
body = "abc",
socketPolicy = DisconnectAfterRequest,
)
),
)
val call = client.newCall(request)