summaryrefslogtreecommitdiff
path: root/ext/http/01_http.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-10-26 22:00:01 +0200
committerGitHub <noreply@github.com>2021-10-26 22:00:01 +0200
commitc27ef0ac7b5fd7aba4de24292e80387c8243896e (patch)
treecb2ce5631491245d12777e62d0696580b080bef8 /ext/http/01_http.js
parentc5a35aba82f5cb24f0ba478875e492dd9ae0524d (diff)
perf(http): encode string bodies in op-layer (#12451)
Using serde_v8's StringOrBuffer
Diffstat (limited to 'ext/http/01_http.js')
-rw-r--r--ext/http/01_http.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/http/01_http.js b/ext/http/01_http.js
index 4e6b8fc00..9ce6997c6 100644
--- a/ext/http/01_http.js
+++ b/ext/http/01_http.js
@@ -199,11 +199,17 @@
SetPrototypeDelete(httpConn.managedResources, responseSenderRid);
let responseBodyRid;
try {
- responseBodyRid = await core.opAsync("op_http_response", [
- responseSenderRid,
- innerResp.status ?? 200,
- innerResp.headerList,
- ], respBody instanceof Uint8Array ? respBody : null);
+ responseBodyRid = await core.opAsync(
+ "op_http_response",
+ [
+ responseSenderRid,
+ innerResp.status ?? 200,
+ innerResp.headerList,
+ ],
+ (respBody instanceof Uint8Array || typeof respBody === "string")
+ ? respBody
+ : null,
+ );
} catch (error) {
const connError = httpConn[connErrorSymbol];
if (error instanceof BadResource && connError != null) {