mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
Fixed network restoration
commit_hash:3cf163db68f76561800ac8e530e435a09f625e62
This commit is contained in:
+2
-4
@@ -38,10 +38,8 @@ private fun Throwable?.isNetworkConnectivityError(): Boolean {
|
||||
is ConnectException,
|
||||
is SocketTimeoutException,
|
||||
is SocketException,
|
||||
is InterruptedIOException -> return true
|
||||
is HttpException -> {
|
||||
if (cause.response.code == 408 || cause.response.code == 504) return true
|
||||
}
|
||||
is InterruptedIOException,
|
||||
is HttpException -> return true
|
||||
}
|
||||
cause = cause.cause
|
||||
}
|
||||
|
||||
+4
-19
@@ -68,23 +68,8 @@ class ImageNetworkRestorationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `restarts on HTTP 504`() = expectRestart {
|
||||
httpErrorResult(it, code = 504)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `restarts on HTTP 408`() = expectRestart {
|
||||
httpErrorResult(it, code = 408)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `does not restart on HTTP 500`() = expectNoRestart {
|
||||
httpErrorResult(it, code = 500)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `does not restart on HTTP 404`() = expectNoRestart {
|
||||
httpErrorResult(it, code = 404)
|
||||
fun `restarts on HTTP error result`() = expectRestart {
|
||||
httpErrorResult(it)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,10 +186,10 @@ class ImageNetworkRestorationTest {
|
||||
throwable = UnknownHostException("offline"),
|
||||
)
|
||||
|
||||
private fun httpErrorResult(request: ImageRequest, code: Int): ErrorResult =
|
||||
private fun httpErrorResult(request: ImageRequest): ErrorResult =
|
||||
ErrorResult(
|
||||
image = null,
|
||||
request = request,
|
||||
throwable = HttpException(NetworkResponse().copy(code = code)),
|
||||
throwable = HttpException(NetworkResponse()),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user