diff --git a/lib/index.js b/lib/index.js index 6c105a0..eeefc45 100644 --- a/lib/index.js +++ b/lib/index.js @@ -124,9 +124,21 @@ exports.request = function (url, opts) { // string if (!body || 'string' === typeof body || body instanceof Buffer) { + if (debugBody.enabled) { + if (!body) { + debugBody(''); + } else if ('string' === typeof body) { + debugBody(body); + } else { + debugBody(`Buffer , Buffer length: ${body.length}`); + } + } request.end(body); } else if ('function' === typeof body.pipe) { // stream body.pipe(request); + if (debugBody.enabled) { + debugBody(''); + } body.once('error', (err) => { abort(append(err, 'HttpX', 'Stream occor error')); }); @@ -223,7 +235,7 @@ exports.read = function (response, encoding) { return resolve(result); } - debugBody('Buffer '); + debugBody(`Buffer , Buffer length: ${buff.length}`); resolve(buff); };