Skip compression in case of empty string body (#1080)

* Fix #1069

* Updated test

* Updated test
This commit is contained in:
Tomas Della Vedova
2020-02-04 10:28:42 +01:00
committed by delvedor
parent e23cc725f6
commit 5a0bcfd83f
3 changed files with 58 additions and 10 deletions

View File

@ -123,15 +123,17 @@ class Transport {
return callback(err, result)
}
}
headers['Content-Type'] = headers['Content-Type'] || 'application/json'
if (compression === 'gzip') {
if (isStream(params.body) === false) {
params.body = intoStream(params.body).pipe(createGzip())
} else {
params.body = params.body.pipe(createGzip())
if (params.body !== '') {
headers['Content-Type'] = headers['Content-Type'] || 'application/json'
if (compression === 'gzip') {
if (isStream(params.body) === false) {
params.body = intoStream(params.body).pipe(createGzip())
} else {
params.body = params.body.pipe(createGzip())
}
headers['Content-Encoding'] = compression
}
headers['Content-Encoding'] = compression
}
if (isStream(params.body) === false) {