Skip to content

Commit

Permalink
Adjust #3292
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Aug 26, 2016
1 parent 49a60d5 commit 4278425
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
13 changes: 11 additions & 2 deletions lib/compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,17 @@ internals.Compression.prototype.encoding = function (response) {
}

const mime = request.server.mime.type(response.headers['content-type'] || 'application/octet-stream');
const encoding = (mime.compressible && !response.headers['content-encoding'] ? request.info.acceptEncoding : null);
return (encoding === 'identity' ? null : encoding);
if (!mime.compressible) {
return null;
}

response.vary('accept-encoding');

if (response.headers['content-encoding']) {
return null;
}

return (request.info.acceptEncoding === 'identity' ? null : request.info.acceptEncoding);
};


Expand Down
2 changes: 0 additions & 2 deletions lib/transmit.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ internals.transmit = function (response, callback) {

// Content-Encoding

response.vary('accept-encoding');

let compressor = null;
if (encoding &&
length !== 0 &&
Expand Down
1 change: 1 addition & 0 deletions test/transmit.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ describe('transmission', () => {
expect(res.headers['content-type']).to.equal('image/png');
expect(res.headers['content-encoding']).to.not.exist();
expect(res.headers['content-length']).to.equal(42010);
expect(res.headers.vary).to.not.exist();
expect(res.payload).to.exist();
done();
});
Expand Down

0 comments on commit 4278425

Please sign in to comment.