diff --git a/lib/core/util.js b/lib/core/util.js index 76714f61d32..2bad24df2f6 100644 --- a/lib/core/util.js +++ b/lib/core/util.js @@ -212,7 +212,7 @@ function bodyLength (body) { : null } else if (isBlobLike(body)) { return body.size != null ? body.size : null - } else if (Buffer.isBuffer(body)) { + } else if (isBuffer(body)) { return body.byteLength } @@ -341,10 +341,12 @@ function parseRawHeaders (headers) { return ret } + function isBuffer (buffer) { // See, https://github.com/mcollina/undici/pull/319 return buffer instanceof Uint8Array || Buffer.isBuffer(buffer) } + function validateHandler (handler, method, upgrade) { if (!handler || typeof handler !== 'object') { throw new InvalidArgumentError('handler must be an object')