Skip to content

Commit 490b201

Browse files
committed
perf(model-client): stricter limit of the body size in pushObjects
The body was previously limit by the number of entries, but some entries are bigger than others. In some cases the body was too big causing a `413 Request Entity Too Large`. Now that actual serialized size of the entries is used to split them into chunks.
1 parent adf2dea commit 490b201

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

model-client/src/commonMain/kotlin/org/modelix/model/client2/ModelClientV2.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,9 @@ class ModelClientV2(
347347
val entrySize = (if (chunkContent.isEmpty()) 0 else 1) + entry.first.length + 1 + entry.second.length
348348
if (chunkContent.length + entrySize > maxBodySize) {
349349
sendChunk()
350-
} else {
351-
if (chunkContent.isNotEmpty()) chunkContent.append('\n')
352-
chunkContent.append(entry.first).append('\n').append(entry.second)
353350
}
351+
if (chunkContent.isNotEmpty()) chunkContent.append('\n')
352+
chunkContent.append(entry.first).append('\n').append(entry.second)
354353
}
355354
if (chunkContent.isNotEmpty()) sendChunk()
356355
}

0 commit comments

Comments
 (0)