MCPcopy Create free account
hub / github.com/nodejs/undici / setEncoding

Method setEncoding

lib/api/readable.js:326–339  ·  view source on GitHub ↗

* @param {BufferEncoding} encoding * @returns {this}

(encoding)

Source from the content-addressed store, hash-verified

324 * @returns {this}
325 */
326 setEncoding (encoding) {
327 if (Buffer.isEncoding(encoding)) {
328 // Delegate to Node.js Readable.setEncoding() which initializes a
329 // StringDecoder and re-encodes already-buffered chunks. This properly
330 // handles multi-byte sequences split at chunk boundaries for the
331 // for-await / on('data') paths. Without this, Node.js uses
332 // buf.toString(encoding) on each chunk, producing U+FFFD for split chars.
333 //
334 // The consume path (body.text(), body.json(), ...) copes with the
335 // decoded strings this leaves in state.buffer, see consumeStart().
336 super.setEncoding(encoding)
337 }
338 return this
339 }
340}
341
342/**

Callers 15

retry-agent.jsFile · 0.80
postServerFunction · 0.80
client.jsFile · 0.80
issue-4691.jsFile · 0.80
client-request.jsFile · 0.80
readable.jsFile · 0.80
bodyFunction · 0.80
postServerFunction · 0.80
readBodyFunction · 0.80
proxy.jsFile · 0.80
http2.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected