From 4bfedec3f148c252aa3794ee65712c70c5fbf1b9 Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Wed, 13 Jan 2016 13:54:05 +0500 Subject: [PATCH] check for pipe method only (part 2) Don't know why I didn't replace all calls to isStream. This fix error on passing Stream from multiparty. Related https://github.com/sindresorhus/got/commit/5205e7260f6082fe567f505be4aa15249c2c74a5 --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 0d89b24..6cf8c3b 100644 --- a/index.js +++ b/index.js @@ -143,7 +143,7 @@ function asStream(opts) { ee.on('request', req => { proxy.emit('request', req); - if (isStream.readable(opts.body)) { + if (isStream(opts.body)) { opts.body.pipe(req); return; } @@ -223,7 +223,7 @@ function normalizeArguments(url, opts) { let body = opts.body; if (body) { - if (typeof body !== 'string' && !Buffer.isBuffer(body) && !isStream.readable(body) && !isPlainObj(body)) { + if (typeof body !== 'string' && !Buffer.isBuffer(body) && !isStream(body) && !isPlainObj(body)) { throw new Error('options.body must be a ReadableStream, string, Buffer or plain Object'); } @@ -234,7 +234,7 @@ function normalizeArguments(url, opts) { body = opts.body = querystring.stringify(body); } - if (opts.headers['content-length'] === undefined && opts.headers['transfer-encoding'] === undefined && !isStream.readable(body)) { + if (opts.headers['content-length'] === undefined && opts.headers['transfer-encoding'] === undefined && !isStream(body)) { const length = typeof body === 'string' ? Buffer.byteLength(body) : body.length; opts.headers['content-length'] = length; }