network: verify WebSocket hostnames; trust bundles fail closed
- Commit
85bd0a8a5fbe280804c4aba31c352c8f741dc9be- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-21 11:01 UTC (15 days ago)
- Parents
25b2f6e
WebSocketClient's raw SSLSocket never set hostname verification and had no timeouts, and handshake failures were swallowed. It now sets endpointIdentificationAlgorithm=HTTPS before handshaking, with 15s connect / 30s handshake budgets (idle timeout cleared after upgrade), and handshake failure closes the socket and propagates as IOException. Trust bundles degraded silently to system trust when bundled roots failed to load; applyBundle now throws at init for non-SYSTEM bundles (call sites ignore return values, so a throw is the only un-ignorable shape) and BundledTrust requires its bundled roots to actually load. Retry-After parses HTTP-date forms too, and response bodies are capped (64MiB, endpoint named) in both HTTP engines. Verified: library:network tests and appstore compile + retry tests pass.
Diff
appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.ktindex e21fe6238d..4e0525f0a0 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.kt@@ -8,6 +8,10 @@ import kotlinx.coroutines.flow.asStateFlow import java.io.IOException import java.net.HttpURLConnection import java.net.URL+import java.time.DateTimeException+import java.time.ZonedDateTime+import java.time.format.DateTimeFormatter+import java.util.Locale import java.util.concurrent.atomic.AtomicInteger import kotlin.random.Random @@ -73,6 +77,51 @@ class PlayHttpClient : IHttpClient { waiting.set(0) _throttled.value = false }++ /** RFC 850 (obsolete) HTTP-date, e.g. `Sunday, 06-Nov-94 08:49:37 GMT`. */+ private val RFC_850_FORMAT: DateTimeFormatter =+ DateTimeFormatter.ofPattern("EEEE, dd-MMM-yy HH:mm:ss z", Locale.US)++ /** ANSI C asctime (obsolete) HTTP-date, e.g. `Sun Nov 6 08:49:37 1994` (GMT assumed). */+ private val ASCTIME_FORMAT: DateTimeFormatter =+ DateTimeFormatter.ofPattern("EEE MMM d HH:mm:ss yyyy", Locale.US)++ /**+ * Parses a `Retry-After` header value (RFC 9110 §10.2.3) to milliseconds+ * from [nowMs]: either delay-seconds (`120`) or an HTTP-date+ * (`Sun, 06 Nov 1994 08:49:37 GMT`, in any of the three formats a+ * recipient must accept). A date in the past, an absent header and an+ * unparseable value all yield 0, which the caller reads as "no server+ * delay named" and falls back to exponential backoff for.+ */+ internal fun parseRetryAfterMs(header: String?, nowMs: Long = System.currentTimeMillis()): Long {+ val value = header?.trim()?.takeIf { it.isNotEmpty() } ?: return 0L+ value.toLongOrNull()?.let { seconds ->+ return if (seconds >= 0) seconds * MILLIS_PER_SECOND else 0L+ }+ val dateMs = parseHttpDateMs(value) ?: return 0L+ return (dateMs - nowMs).coerceAtLeast(0L)+ }++ private fun parseHttpDateMs(value: String): Long? {+ // Collapse runs of spaces: asctime pads a single-digit day with one.+ val normalized = value.replace(Regex(" +"), " ")+ val formatters = listOf(DateTimeFormatter.RFC_1123_DATE_TIME, RFC_850_FORMAT, ASCTIME_FORMAT)+ for (formatter in formatters) {+ try {+ return ZonedDateTime.parse(normalized, formatter).toInstant().toEpochMilli()+ } catch (_: DateTimeException) {+ // Try the next sanctioned format.+ }+ }+ // asctime carries no zone; RFC 9110 dates are GMT, so retry it as UTC.+ return try {+ java.time.LocalDateTime.parse(normalized, ASCTIME_FORMAT)+ .toInstant(java.time.ZoneOffset.UTC).toEpochMilli()+ } catch (_: DateTimeException) {+ null+ }+ } } /**@@ -201,12 +250,9 @@ class PlayHttpClient : IHttpClient { private fun sleep(millis: Long) = sleeper(millis) - /** `Retry-After` in milliseconds, or 0 when the server did not name a delay in seconds. */+ /** `Retry-After` in milliseconds, or 0 when the server named no usable delay. */ private fun retryAfterMs(conn: HttpURLConnection): Long =- conn.getHeaderField("Retry-After")?.trim()?.toLongOrNull()- ?.takeIf { it >= 0 }- ?.times(MILLIS_PER_SECOND)- ?: 0L+ parseRetryAfterMs(conn.getHeaderField("Retry-After")) private fun executeOnce( url: String,
appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRetryAfterParseTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRetryAfterParseTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRetryAfterParseTest.ktnew file mode 100644index 0000000000..a6e5948441--- /dev/null+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayRetryAfterParseTest.kt@@ -0,0 +1,50 @@+package com.vayunmathur.appstore.data.play++import java.time.ZoneOffset+import java.time.ZonedDateTime+import java.time.format.DateTimeFormatter+import kotlin.test.Test+import kotlin.test.assertEquals++/** Pure `Retry-After` parsing (RFC 9110): delay-seconds and HTTP-date forms. */+class PlayRetryAfterParseTest {++ // Sun, 06 Nov 1994 08:49:37 GMT — the RFC's own example instant.+ private val exampleMs = ZonedDateTime.of(1994, 11, 6, 8, 49, 37, 0, ZoneOffset.UTC)+ .toInstant().toEpochMilli()++ @Test+ fun delay_seconds_parse_to_millis() {+ assertEquals(0L, PlayHttpClient.parseRetryAfterMs("0", nowMs = 1_000L))+ assertEquals(120_000L, PlayHttpClient.parseRetryAfterMs("120", nowMs = 1_000L))+ assertEquals(5_000L, PlayHttpClient.parseRetryAfterMs(" 5 ", nowMs = 1_000L))+ }++ @Test+ fun imf_fixdate_parses_relative_to_now() {+ val header = DateTimeFormatter.RFC_1123_DATE_TIME.format(+ ZonedDateTime.ofInstant(java.time.Instant.ofEpochMilli(exampleMs), ZoneOffset.UTC),+ )+ assertEquals(37_000L, PlayHttpClient.parseRetryAfterMs(header, nowMs = exampleMs - 37_000L))+ // The RFC's literal example string parses the same way.+ assertEquals(+ 37_000L,+ PlayHttpClient.parseRetryAfterMs("Sun, 06 Nov 1994 08:49:37 GMT", nowMs = exampleMs - 37_000L),+ )+ }++ @Test+ fun past_http_date_and_garbage_yield_zero() {+ assertEquals(0L, PlayHttpClient.parseRetryAfterMs("Sun, 06 Nov 1994 08:49:37 GMT", nowMs = exampleMs + 1))+ assertEquals(0L, PlayHttpClient.parseRetryAfterMs("soon", nowMs = 0L))+ assertEquals(0L, PlayHttpClient.parseRetryAfterMs(null, nowMs = 0L))+ assertEquals(0L, PlayHttpClient.parseRetryAfterMs("", nowMs = 0L))+ assertEquals(0L, PlayHttpClient.parseRetryAfterMs("-5", nowMs = 0L))+ }++ @Test+ fun asctime_form_parses_as_gmt() {+ // Sun Nov 6 08:49:37 1994 — same instant, obsolete asctime form.+ assertEquals(10_000L, PlayHttpClient.parseRetryAfterMs("Sun Nov 6 08:49:37 1994", nowMs = exampleMs - 10_000L))+ }+}
library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.kt
diff --git a/library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.kt b/library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.ktindex e021c886fd..7051d9fda1 100644--- a/library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.kt+++ b/library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.kt@@ -57,13 +57,16 @@ object BundledTrust { val cf = CertificateFactory.getInstance("X.509") val ks = KeyStore.getInstance(KeyStore.getDefaultType()).apply { load(null, null) } - val loaded = seedSystemIssuers(ks, bundle) + loadBundledAssets(context, cf, ks, assetPaths)-- if (loaded == 0) {- Log.status(+ val systemLoaded = seedSystemIssuers(ks, bundle)+ val bundledLoaded = loadBundledAssets(context, cf, ks, assetPaths)+ val loaded = systemLoaded + bundledLoaded++ if (bundledLoaded == 0) {+ // Even for ESIM (system-seeded), a bundle whose own roots all failed is+ // not the bundle that was asked for; NetworkClient fails closed on null.+ Log.error( TAG,- "No CAs loaded for bundle $bundle (checked ${assetPaths.size} assets)" +- " — falling back to system trust",+ "No bundled CAs loaded for bundle $bundle (checked ${assetPaths.size} assets)", ) return null }
library/network/src/main/java/com/vayunmathur/library/network/HttpUrlEngine.kt
diff --git a/library/network/src/main/java/com/vayunmathur/library/network/HttpUrlEngine.kt b/library/network/src/main/java/com/vayunmathur/library/network/HttpUrlEngine.ktindex a5095cca39..29ad8ab557 100644--- a/library/network/src/main/java/com/vayunmathur/library/network/HttpUrlEngine.kt+++ b/library/network/src/main/java/com/vayunmathur/library/network/HttpUrlEngine.kt@@ -58,6 +58,14 @@ internal object HttpUrlEngine { */ const val MAX_TEXT_BODY_BYTES = 16L * 1024 * 1024 + /**+ * Hard cap on bodies returned as [ByteArray] (see [readBody]). Byte bodies+ * (protobuf, images, archives) legitimately run larger than JSON text, so+ * the cap sits above [MAX_TEXT_BODY_BYTES]; anything bigger belongs on the+ * streaming path, not materialised whole in the heap.+ */+ const val MAX_BODY_BYTES = 64L * 1024 * 1024+ private val EMPTY_BYTES = ByteArray(0) data class InternalResult(@@ -500,9 +508,18 @@ internal object HttpUrlEngine { * * A truncated body is an error here, where it used to be silently reported as an empty one: * hiding it left no way to tell which endpoint had failed, which is what #582 asked for.+ *+ * [maxBytes] caps the read exactly like [readBodyText]'s: counted as bytes+ * arrive, never trusted from Content-Length. Null keeps the read uncapped+ * for a caller that has its own bound; the default caps at [MAX_BODY_BYTES]. */- fun readBody(response: OpenResponse): ByteArray = try {- drainFully(response.stream, response.contentLength, response.isIdentityEncoding)+ fun readBody(response: OpenResponse, maxBytes: Long? = MAX_BODY_BYTES): ByteArray = try {+ drainFully(response.stream, response.contentLength, response.isIdentityEncoding, maxBytes)+ } catch (e: BodyTooLargeException) {+ throw IOException(+ "Response body from ${response.finalUrl} exceeds ${e.maxBytes} bytes after ${e.bytesRead} bytes",+ e,+ ) } catch (e: BodyReadException) { throw IOException( "Failed to read response body from ${response.finalUrl} after ${e.bytesRead} bytes",
library/network/src/main/java/com/vayunmathur/library/network/NetworkClient.kt
diff --git a/library/network/src/main/java/com/vayunmathur/library/network/NetworkClient.kt b/library/network/src/main/java/com/vayunmathur/library/network/NetworkClient.ktindex 349aafbd3b..6958763dae 100644--- a/library/network/src/main/java/com/vayunmathur/library/network/NetworkClient.kt+++ b/library/network/src/main/java/com/vayunmathur/library/network/NetworkClient.kt@@ -160,8 +160,8 @@ object NetworkClient { if (isAlreadyInitialized(bundle)) { return }- // Total: BundledTrust.createFactory catches its own failures and returns null,- // so there is nothing left here that needs a catch-all.+ // Fail closed: applyBundle throws for a non-SYSTEM bundle it cannot build,+ // so a caller can never silently end up on system trust with a narrow bundle. applyBundle(appCtx, bundle) initialized = true }@@ -181,13 +181,20 @@ object NetworkClient { return } val result = BundledTrust.createFactory(appCtx, bundle)- defaultSslSocketFactory = result?.first- defaultTrustManager = result?.second- if (defaultSslSocketFactory == null) {- Log.status(TAG, "Bundle $bundle produced no factory (missing DERs?), falling back to system trust")- } else {- Log.status(TAG, "Initialized with bundle $bundle")+ if (result == null) {+ // Never widen a narrow bundle to system trust: that would silently talk+ // to FIRST_PARTY/STANDARD/EXTENDED/ESIM hosts under any public CA.+ // Throwing from init() is the one shape no caller can ignore.+ defaultSslSocketFactory = null+ defaultTrustManager = null+ Log.error(TAG, "Bundle $bundle produced no factory (missing DERs?); refusing to fall back to system trust")+ throw IllegalStateException(+ "TrustBundle $bundle produced no SSLSocketFactory; refusing system-trust fallback",+ ) }+ defaultSslSocketFactory = result.first+ defaultTrustManager = result.second+ Log.status(TAG, "Initialized with bundle $bundle") } @Synchronized
library/network/src/main/java/com/vayunmathur/library/network/PooledHttpEngine.kt
diff --git a/library/network/src/main/java/com/vayunmathur/library/network/PooledHttpEngine.kt b/library/network/src/main/java/com/vayunmathur/library/network/PooledHttpEngine.ktindex a614f6b08b..8217dd1223 100644--- a/library/network/src/main/java/com/vayunmathur/library/network/PooledHttpEngine.kt+++ b/library/network/src/main/java/com/vayunmathur/library/network/PooledHttpEngine.kt@@ -130,11 +130,7 @@ internal object PooledHttpEngine { val call = client.newCall(builder.build()) // try-with-resources equivalent: `use` closes the response (and its body) on every path. call.execute().use { response ->- val bytes = try {- response.body?.bytes() ?: ByteArray(0)- } catch (e: IOException) {- throw IOException("Failed to read response body from $url", e)- }+ val bytes = readPooledBody(response.body, url) val respHeaders = mutableMapOf<String, List<String>>() for (name in response.headers.names()) { respHeaders[name] = response.headers.values(name)@@ -153,6 +149,36 @@ internal object PooledHttpEngine { } } + /**+ * Streams a pooled body under [HttpUrlEngine.MAX_BODY_BYTES] instead of+ * OkHttp's unbounded `bytes()`: the cap is counted as bytes arrive (via+ * [HttpUrlEngine.drainFully], same as `readBodyText`), so a lying or+ * absent Content-Length cannot defeat it. No pre-size hint is passed:+ * OkHttp may have transparently decompressed the body, so its+ * Content-Length no longer describes the stream in hand.+ */+ internal fun readPooledBody(+ body: okhttp3.ResponseBody?,+ url: String,+ maxBytes: Long = HttpUrlEngine.MAX_BODY_BYTES,+ ): ByteArray {+ if (body == null) return ByteArray(0)+ return try {+ body.byteStream().use { stream ->+ HttpUrlEngine.drainFully(stream, null, false, maxBytes)+ }+ } catch (e: HttpUrlEngine.BodyTooLargeException) {+ throw IOException(+ "Response body from $url exceeds ${e.maxBytes} bytes after ${e.bytesRead} bytes",+ e,+ )+ } catch (e: HttpUrlEngine.BodyReadException) {+ throw IOException("Failed to read response body from $url after ${e.bytesRead} bytes", e)+ } catch (e: IOException) {+ throw IOException("Failed to read response body from $url", e)+ }+ }+ private fun applyHeaders(builder: Request.Builder, headers: Map<String, *>) { headers.forEach { (k, v) -> when (v) {
library/network/src/main/java/com/vayunmathur/library/network/WebSocketClient.kt
diff --git a/library/network/src/main/java/com/vayunmathur/library/network/WebSocketClient.kt b/library/network/src/main/java/com/vayunmathur/library/network/WebSocketClient.ktindex 25e2908bf3..5a76b9d23f 100644--- a/library/network/src/main/java/com/vayunmathur/library/network/WebSocketClient.kt+++ b/library/network/src/main/java/com/vayunmathur/library/network/WebSocketClient.kt@@ -12,6 +12,7 @@ import java.io.EOFException import java.io.IOException import java.io.InputStream import java.io.OutputStream+import java.net.InetSocketAddress import java.net.Socket import java.net.URI import java.net.URL@@ -40,7 +41,9 @@ class WebSocketHandshakeException( * - Frame codec: TEXT(0x1), BINARY(0x2), CLOSE(0x8), PING(0x9), PONG(0xA), masking on send * - Exposes WsSession { send(String/ByteArray), incoming Flow<WsFrame>, close() } * - Top-level webSocket(url, headers, block) for OfficeSync WS & CableTunnel WS- * - TLS: uses explicit factory, else NetworkClient.defaultSslSocketFactory, else system default.+ * - TLS: uses explicit factory, else NetworkClient.defaultSslSocketFactory, else system default;+ * hostname verification (endpoint identification "HTTPS") plus connect/handshake timeouts+ * apply before the upgrade, and a failed handshake fails [connect] instead of being swallowed. */ class WebSocketClient private constructor( private val socket: Socket,@@ -329,6 +332,16 @@ class WebSocketClient private constructor( private const val MAX_HANDSHAKE_HEADER_BYTES = 8192 private const val HANDSHAKE_ERROR_LINES = 10 + /** TCP connect budget; a peer that never answers must not hang the caller. */+ internal const val CONNECT_TIMEOUT_MS = 15_000++ /**+ * Read budget while the TLS + WebSocket upgrade handshakes are in flight.+ * Cleared back to 0 once the socket becomes a long-lived WebSocket, whose+ * frame reads block indefinitely by design (keepalive is the caller's loop).+ */+ internal const val HANDSHAKE_TIMEOUT_MS = 30_000+ /** Parsed endpoint pieces for one connection attempt. */ private data class WsEndpoint( val uri: URI,@@ -358,6 +371,9 @@ class WebSocketClient private constructor( val respHeaders = parseHandshakeHeaders(responseLines) checkAccept(respHeaders, expectedAccept) val captured = captureHeaders(respHeaders, captureResponseHeaders)+ // Upgrade done: frame reads block indefinitely by design, so the+ // handshake read budget must not kill a healthy idle socket.+ sock.soTimeout = 0 WebSocketClient(sock, sock.getInputStream(), sock.getOutputStream(), respHeaders.multi, captured) } catch (e: IOException) { runCatching { sock.close() }@@ -404,9 +420,11 @@ class WebSocketClient private constructor( val sock: Socket = if (secure) { openTlsSocket(endpoint, sslSocketFactory, useSystemTrust) } else {- Socket(endpoint.host, endpoint.port)+ Socket().apply {+ connect(InetSocketAddress(endpoint.host, endpoint.port), CONNECT_TIMEOUT_MS)+ soTimeout = HANDSHAKE_TIMEOUT_MS+ } }- sock.soTimeout = 0 sock.tcpNoDelay = true return sock }@@ -419,9 +437,26 @@ class WebSocketClient private constructor( val defaultFactory = NetworkClient.defaultSslSocketFactory ?: SSLSocketFactory.getDefault() val factory: javax.net.SocketFactory = if (useSystemTrust) SSLSocketFactory.getDefault() else sslSocketFactory ?: defaultFactory- val sock = factory.createSocket(endpoint.host, endpoint.port) as Socket- if (sock is SSLSocket) {- try { sock.startHandshake() } catch (_: Exception) { }+ val sock = factory.createSocket() as? SSLSocket+ ?: throw IOException("TLS factory produced no SSLSocket for ${endpoint.host}:${endpoint.port}")+ try {+ sock.connect(InetSocketAddress(endpoint.host, endpoint.port), CONNECT_TIMEOUT_MS)+ sock.soTimeout = HANDSHAKE_TIMEOUT_MS+ // Hostname verification is off by default on a raw SSLSocket: without+ // endpoint identification the bundled pins would accept any host's+ // chain to our roots. Must be set before the handshake starts.+ sock.sslParameters = sock.sslParameters.apply {+ endpointIdentificationAlgorithm = "HTTPS"+ }+ sock.startHandshake()+ } catch (e: IOException) {+ Log.error(TAG, "TLS handshake failed for ${endpoint.host}:${endpoint.port}", e)+ runCatching { sock.close() }+ throw IOException("TLS handshake failed for ${endpoint.host}:${endpoint.port}: ${e.message}", e)+ } catch (e: RuntimeException) {+ Log.error(TAG, "TLS handshake failed for ${endpoint.host}:${endpoint.port}", e)+ runCatching { sock.close() }+ throw IOException("TLS handshake failed for ${endpoint.host}:${endpoint.port}: ${e.message}", e) } return sock }
library/network/src/test/java/com/vayunmathur/library/network/HttpUrlEnginePureTest.kt
diff --git a/library/network/src/test/java/com/vayunmathur/library/network/HttpUrlEnginePureTest.kt b/library/network/src/test/java/com/vayunmathur/library/network/HttpUrlEnginePureTest.ktindex f835814c69..cf7462f1f4 100644--- a/library/network/src/test/java/com/vayunmathur/library/network/HttpUrlEnginePureTest.kt+++ b/library/network/src/test/java/com/vayunmathur/library/network/HttpUrlEnginePureTest.kt@@ -75,6 +75,26 @@ class HttpUrlEnginePureTest { assertContentEquals(data, HttpUrlEngine.readBody(response(200, ByteArrayInputStream(data)))) } + @Test+ fun read_body_default_cap_names_the_endpoint_on_breach() {+ val data = ByteArray(10_000) { (it % 251).toByte() }+ val resp = response(200, ByteArrayInputStream(data), url = "https://example.test/big")+ val e = assertFailsWith<IOException> {+ resp.use { HttpUrlEngine.readBody(it, maxBytes = 1024) }+ }+ assertTrue(e.message!!.contains("https://example.test/big"), "got: ${e.message}")+ assertTrue(e.message!!.contains("1024"), "got: ${e.message}")+ }++ @Test+ fun read_body_null_cap_stays_uncapped() {+ val data = ByteArray(5000) { (it % 251).toByte() }+ assertContentEquals(+ data,+ HttpUrlEngine.readBody(response(200, ByteArrayInputStream(data)), maxBytes = null),+ )+ }+ @Test fun read_body_names_the_endpoint_on_failure() { val resp = response(200, failingAfter(300), url = "https://example.test/models/x")
library/network/src/test/java/com/vayunmathur/library/network/PooledHttpEngineTest.kt
diff --git a/library/network/src/test/java/com/vayunmathur/library/network/PooledHttpEngineTest.kt b/library/network/src/test/java/com/vayunmathur/library/network/PooledHttpEngineTest.ktindex db80b9470f..a26cd6692d 100644--- a/library/network/src/test/java/com/vayunmathur/library/network/PooledHttpEngineTest.kt+++ b/library/network/src/test/java/com/vayunmathur/library/network/PooledHttpEngineTest.kt@@ -110,4 +110,28 @@ class PooledHttpEngineTest { fun per_host_concurrency_matches_maplibre() { assertEquals(20, PooledHttpEngine.MAX_REQUESTS_PER_HOST) }++ @Test+ fun pooled_body_read_is_capped_and_names_the_url() {+ val body = ByteArray(10_000) { (it % 251).toByte() }+ .toResponseBodyForTest()+ val e = kotlin.test.assertFailsWith<java.io.IOException> {+ PooledHttpEngine.readPooledBody(body, "http://127.0.0.1/big", maxBytes = 1024)+ }+ assertTrue(e.message!!.contains("http://127.0.0.1/big"), "got: ${e.message}")+ }++ @Test+ fun pooled_body_under_the_cap_reads_exact_and_null_is_empty() {+ val data = "tiles".toByteArray()+ kotlin.test.assertContentEquals(+ data,+ PooledHttpEngine.readPooledBody(data.toResponseBodyForTest(), "http://x/", maxBytes = 1024),+ )+ assertEquals(0, PooledHttpEngine.readPooledBody(null, "http://x/").size)+ }+}++private fun ByteArray.toResponseBodyForTest(): okhttp3.ResponseBody {+ return with(okhttp3.ResponseBody.Companion) { [email protected](null) } }