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

Content-Encoding header is not set properly from rule, only from options #39

Open
monrax opened this issue Feb 21, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@monrax
Copy link
Member

monrax commented Feb 21, 2024

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.

@monrax monrax changed the title header is not set properly when skip_compression rule is present Content-Encoding header is not set properly from rule, only from options Feb 21, 2024
@monrax
Copy link
Member Author

monrax commented Feb 21, 2024

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

@monrax monrax self-assigned this Feb 21, 2024
@monrax monrax added the bug Something isn't working label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant