Skip to content

Commit

Permalink
fix: decompress response data
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffersonfelixdev committed Nov 23, 2022
1 parent fdb9c2b commit 24a739b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/adapters/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,11 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
if (config.decompress !== false) {
// if no content, but headers still say that it is encoded,
// remove the header not confuse downstream operations
if ((!responseLength || res.statusCode === 204) && res.headers['content-encoding']) {
if (
(!responseLength || res.statusCode === 204) &&
res.headers['content-encoding'] &&
!res.headers['transfer-encoding']
) {
delete res.headers['content-encoding'];
}

Expand Down
1 change: 1 addition & 0 deletions test/unit/adapters/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ describe('supports http with nodejs', function () {
server = http.createServer(function(req, res) {
res.setHeader('Content-Type', 'text/html;charset=utf-8');
res.setHeader('Content-Encoding', 'gzip');
res.setHeader('Transfer-Encoding', 'chunked');
res.end(zipped);
}).listen(4444, function() {
axios.get('http://localhost:4444/', {
Expand Down

0 comments on commit 24a739b

Please sign in to comment.