diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2022-11-09 17:20:05 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 17:20:05 +0900 |
commit | 9edcab524fef558abce824731e78f83f7aac28dd (patch) | |
tree | bb78f8e648500d954dcde8d1a9f9bb153d63da98 /ext/flash/01_http.js | |
parent | c08fcd96c1d2e903101718c4792d2b5faec94b24 (diff) |
fix(ext/flash): revert #16284 and add test case (#16576)
Diffstat (limited to 'ext/flash/01_http.js')
-rw-r--r-- | ext/flash/01_http.js | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js index df013ce65..4435860ff 100644 --- a/ext/flash/01_http.js +++ b/ext/flash/01_http.js @@ -371,8 +371,6 @@ } } else { const reader = respBody.getReader(); - const { value, done } = await reader.read(); - // Best case: sends headers + first chunk in a single go. writeFixedResponse( serverId, i, @@ -387,21 +385,14 @@ false, respondFast, ); - await respondChunked( - i, - value, - done, - ); - if (!done) { - while (true) { - const chunk = await reader.read(); - await respondChunked( - i, - chunk.value, - chunk.done, - ); - if (chunk.done) break; - } + while (true) { + const { value, done } = await reader.read(); + await respondChunked( + i, + value, + done, + ); + if (done) break; } } } @@ -632,22 +623,13 @@ }); function respondChunked(token, chunk, shutdown) { - const nwritten = core.ops.op_try_flash_respond_chuncked( + return core.opAsync( + "op_flash_respond_chuncked", serverId, token, - chunk ?? new Uint8Array(), + chunk, shutdown, ); - if (nwritten > 0) { - return core.opAsync( - "op_flash_respond_chuncked", - serverId, - token, - chunk, - shutdown, - nwritten, - ); - } } const fastOp = prepareFastCalls(); |