Skip to content

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

@monrax

Description

@monrax

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions