|
@ -160,7 +160,7 @@ function asStream(opts) { |
|
|
ee.on('request', function (req) { |
|
|
ee.on('request', function (req) { |
|
|
proxy.emit('request', req); |
|
|
proxy.emit('request', req); |
|
|
|
|
|
|
|
|
if (isStream.readable(opts.body)) { |
|
|
if (isStream(opts.body)) { |
|
|
opts.body.pipe(req); |
|
|
opts.body.pipe(req); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
@ -240,7 +240,7 @@ function normalizeArguments(url, opts) { |
|
|
var body = opts.body; |
|
|
var body = opts.body; |
|
|
|
|
|
|
|
|
if (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'); |
|
|
throw new Error('options.body must be a ReadableStream, string, Buffer or plain Object'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -251,7 +251,7 @@ function normalizeArguments(url, opts) { |
|
|
body = opts.body = querystring.stringify(body); |
|
|
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)) { |
|
|
var length = typeof body === 'string' ? Buffer.byteLength(body) : body.length; |
|
|
var length = typeof body === 'string' ? Buffer.byteLength(body) : body.length; |
|
|
opts.headers['content-length'] = length; |
|
|
opts.headers['content-length'] = length; |
|
|
} |
|
|
} |
|
|