logger-nodejs
logger-nodejs copied to clipboard
Content-Encoding header is not set properly from rule, only from options
Content-Encoding
header is set to deflated
instead of identity
when skip_compression
rule is present as part of options.rules
but not options
itself. This is not the expected result according to the logger API.
Expected behavior
let logger = new HttpLogger({url: 'http://localhost:7701/message', rules: 'include debug\n\nskip_compression'});
console.log(logger._url_options.headers);
//{
// 'Content-Encoding': 'identity',
// 'Content-Type': 'application/json; charset=UTF-8',
// 'User-Agent': 'Resurface/2.2.1 (http_logger.js)'
//}
Current behavior
let logger = new HttpLogger({url: 'http://localhost:7701/message', rules: 'include debug\n\nskip_compression'});
console.log(logger._url_options.headers);
//{
// 'Content-Encoding': 'deflate',
// 'Content-Type': 'application/json; charset=UTF-8',
// 'User-Agent': 'Resurface/2.2.1 (http_logger.js)'
//}
How to reproduce?
const { HttpLogger } = require('resurfaceio-logger');
let logger = new HttpLogger({url: 'http://localhost:7701/message', rules: 'include debug\n\nskip_compression'});
assert.equal(logger.skip_compression, true);
assert.equal(logger._url_options.headers['Content-Encoding'], 'identity'); // fails
The header can also be inspected with a packet capture tool like wireshark, or an HTTP proxy.
The header is set properly, when passing skip_compression: true
as a field to the HttpLogger
constructor.
However, then the skip_compression
field for the object instance is not set.
const { HttpLogger } = require('resurfaceio-logger');
let logger = new HttpLogger({url: 'http://localhost:7701/message', rules: 'include debug', skip_compression: true});
assert.equal(logger._url_options.headers['Content-Encoding'], 'identity'); // pass!
assert.equal(logger.skip_compression, true); // fail