Skip to content

Commit 35231ce

Browse files
committed
add iOS test
1 parent c786b5a commit 35231ce

16 files changed

Lines changed: 718 additions & 1 deletion

File tree

libraries/apollo-runtime/src/appleMain/kotlin/com/apollographql/apollo/network/http/DefaultHttpEngine.apple.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlinx.atomicfu.locks.withLock
1111
import kotlinx.cinterop.alloc
1212
import kotlinx.cinterop.nativeHeap
1313
import kotlinx.cinterop.ptr
14+
import kotlinx.coroutines.CancellationException
1415
import kotlinx.coroutines.suspendCancellableCoroutine
1516
import okio.Buffer
1617
import okio.BufferedSource

libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/network/http/HttpEngine.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.apollographql.apollo.api.http.HttpMethod
99
import com.apollographql.apollo.api.http.HttpRequest
1010
import com.apollographql.apollo.api.http.HttpResponse
1111
import com.apollographql.apollo.exception.ApolloNetworkException
12+
import kotlinx.coroutines.CancellationException
1213
import okio.Closeable
1314

1415
/**
@@ -23,6 +24,7 @@ interface HttpEngine : Closeable {
2324
*
2425
* @throws [ApolloNetworkException] if a network error happens
2526
*/
27+
@Throws(ApolloNetworkException::class, CancellationException::class)
2628
suspend fun execute(request: HttpRequest): HttpResponse
2729

2830
@ApolloDeprecatedSince(v4_0_0)

libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/network/http/HttpInterceptor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@ package com.apollographql.apollo.network.http
22

33
import com.apollographql.apollo.api.http.HttpRequest
44
import com.apollographql.apollo.api.http.HttpResponse
5+
import com.apollographql.apollo.exception.ApolloException
56
import com.apollographql.apollo.exception.ApolloNetworkException
7+
import kotlinx.coroutines.CancellableContinuation
8+
import kotlinx.coroutines.CancellationException
69

710
interface HttpInterceptorChain {
811
/**
9-
* @throws [ApolloNetworkException] if a network error happens
12+
* Continues with the request and call all downstream interceptors.
1013
*/
14+
@Throws(ApolloException::class, CancellationException::class)
1115
suspend fun proceed(request: HttpRequest): HttpResponse
1216
}
1317

1418
interface HttpInterceptor {
19+
/**
20+
* Intercepts the request and returns a response.
21+
* Implementation may throw [ApolloException] in case of error. Those errors are typically
22+
* caught by the network transport and subsequently exposed in `ApolloResponse.exception`
23+
*/
24+
@Throws(ApolloException::class, CancellationException::class)
1525
suspend fun intercept(request: HttpRequest, chain: HttpInterceptorChain): HttpResponse
1626

1727
// TODO: remove dispose

0 commit comments

Comments
 (0)