Handle headers as request option
This commit is contained in:
@ -74,7 +74,7 @@ class Transport {
|
||||
return callback(new NoLivingConnectionsError('There are not living connections'), result)
|
||||
}
|
||||
|
||||
params.headers = params.headers || {}
|
||||
const headers = options.headers || {}
|
||||
// handle json body
|
||||
if (params.body != null) {
|
||||
if (shouldSerialize(params.body) === true) {
|
||||
@ -84,9 +84,9 @@ class Transport {
|
||||
return callback(err, result)
|
||||
}
|
||||
}
|
||||
params.headers['Content-Type'] = 'application/json'
|
||||
headers['Content-Type'] = 'application/json'
|
||||
if (isStream(params.body) === false) {
|
||||
params.headers['Content-Length'] = '' + Buffer.byteLength(params.body)
|
||||
headers['Content-Length'] = '' + Buffer.byteLength(params.body)
|
||||
}
|
||||
// handle ndjson body
|
||||
} else if (params.bulkBody != null) {
|
||||
@ -99,16 +99,17 @@ class Transport {
|
||||
} else {
|
||||
params.body = params.bulkBody
|
||||
}
|
||||
params.headers['Content-Type'] = 'application/x-ndjson'
|
||||
headers['Content-Type'] = 'application/x-ndjson'
|
||||
if (isStream(params.body) === false) {
|
||||
params.headers['Content-Length'] = '' + Buffer.byteLength(params.body)
|
||||
headers['Content-Length'] = '' + Buffer.byteLength(params.body)
|
||||
}
|
||||
}
|
||||
|
||||
if (this.suggestCompression === true) {
|
||||
params.headers['Accept-Encoding'] = 'gzip,deflate'
|
||||
headers['Accept-Encoding'] = 'gzip,deflate'
|
||||
}
|
||||
|
||||
params.headers = headers
|
||||
// serializes the querystring
|
||||
params.querystring = this.serializer.qserialize(params.querystring)
|
||||
// handles request timeout
|
||||
|
||||
Reference in New Issue
Block a user