Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: decompress response data #5300

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: decompress response data
  • Loading branch information
jeffersonfelixdev committed Nov 23, 2022
commit 24a739b6361dee846db21b5b452c6373b155a260
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