ReviewOS

also looking at this

craft-native/craft

fix(mobile): preserve native editing, navigation, and durable media requests

#369
Merged chris wants to merge codex/native-vertical-scroll-tab-swipes into main
36 files +864 -185

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

packages/android/compile-fixtures/CraftNativeResumableDownloadTest.ktmodified+10-2
Changes to packages/android/compile-fixtures/CraftNativeResumableDownloadTest.kt
@@ -50,11 +50,11 @@ class CraftNativeResumableDownloadTest {
5050 else -> 200
5151 }
5252 val bytes = when (code) {
53 206 -> payload.copyOfRange(start!!, payload.size)
53 206 -> payload.copyOfRange(start ?: 0, payload.size)
5454 200 -> payload
5555 else -> byteArrayOf()
5656 }
57 val contentRange = if (code == 206) "Content-Range: bytes $start-${payload.size - 1}/${payload.size}\r\n" else ""
57 val contentRange = if (code == 206 && start != null) "Content-Range: bytes $start-${payload.size - 1}/${payload.size}\r\n" else ""
5858 val headers = "HTTP/1.1 $code Test\r\nContent-Length: ${bytes.size}\r\n${contentRange}Connection: close\r\n\r\n"
5959 socket.getOutputStream().write(headers.toByteArray(Charsets.US_ASCII) + bytes)
6060 }
@@ -126,6 +126,14 @@ class CraftNativeResumableDownloadTest {
126126 }
127127 }
128128
129 @Test
130 fun refusesAnUnsolicitedPartialResponseWithoutRetryingIt() = part { file ->
131 serve(status = 206) { address, _ ->
132 assertEquals(CraftResumableDownload.Fetched.Refused(206), CraftResumableDownload().fetch(address, emptyMap(), file) { false })
133 assertFalse(file.exists())
134 }
135 }
136
129137 @Test
130138 fun refusesAnEmptyResponseWithoutRetainingAnUnresumablePart() = part { file ->
131139 serve(payload = byteArrayOf()) { address, _ ->
packages/android/templates/CraftNativeShell.kt.templatemodified+1-1
Changes to packages/android/templates/CraftNativeShell.kt.template
@@ -1452,7 +1452,7 @@ internal class CraftResumableDownload(
14521452 val resumed = status == 206 && have > 0 && rangeStart(connection.getHeaderField("Content-Range")) == have
14531453 if (status == 416 || (status == 206 && !resumed)) {
14541454 part.delete()
1455 return Fetched.Restart
1455 return if (have > 0) Fetched.Restart else Fetched.Refused(status)
14561456 }
14571457 if (status != 200 && !resumed) {
14581458 part.delete()