WIP: initial prototype
- Added asStream option - Better handling of request object
This commit is contained in:
@ -80,7 +80,8 @@ class Transport {
|
||||
// handles request timeout
|
||||
params.timeout = toMs(params.requestTimeout || this.requestTimeout)
|
||||
|
||||
this.emit('request', params)
|
||||
// TODO: expose nicely the node metadata (also in response an error)
|
||||
this.emit('request', params, connection)
|
||||
|
||||
// perform the actual http request
|
||||
const request = connection.request(params, (err, response) => {
|
||||
@ -116,10 +117,9 @@ class Transport {
|
||||
result.warnings = headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/)
|
||||
}
|
||||
|
||||
// TODO: expose `asStream` option for returning the
|
||||
// body already parsed?
|
||||
if (params.asHttpResponse === true) {
|
||||
callback(null, response)
|
||||
if (params.asStream === true) {
|
||||
result.body = response
|
||||
callback(null, result)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user