diff options
author | Satya Rohith <me@satyarohith.com> | 2024-05-29 11:34:34 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 11:34:34 +0530 |
commit | 4f9b23b3664578c2bf48415db246fb21e49abddb (patch) | |
tree | 2f4d63bd4fdcc9d82dda7c4588dbad119f03a9d3 /ext/node/polyfills | |
parent | a8923534ed02e9e4ba3bb277db6e61a208c64125 (diff) |
fix(ext/node): don't encode buffer data as utf8 in http2 (#24016)
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r-- | ext/node/polyfills/http2.ts | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts index c47e54d1b..efd71ff93 100644 --- a/ext/node/polyfills/http2.ts +++ b/ext/node/polyfills/http2.ts @@ -933,25 +933,23 @@ export class ClientHttp2Stream extends Duplex { // TODO(bartlomieju): clean up _write(chunk, encoding, callback?: () => void) { - debugHttp2(">>> _write", callback); + debugHttp2(">>> _write", encoding, callback); if (typeof encoding === "function") { callback = encoding; - encoding = "utf8"; + encoding = this.#encoding; } let data; - if (typeof encoding === "string") { + if (encoding === "utf8") { data = ENCODER.encode(chunk); - } else { + } else if (encoding === "buffer") { + this.#encoding = encoding; data = chunk.buffer; } this.#requestPromise .then(() => { debugHttp2(">>> _write", this.#rid, data, encoding, callback); - return op_http2_client_send_data( - this.#rid, - data, - ); + return op_http2_client_send_data(this.#rid, new Uint8Array(data)); }) .then(() => { callback?.(); |