Skip to content

Replace accepts with negotiator - #197

Merged
bjohansebas merged 1 commit into
masterfrom
be/use-negotiator
Oct 25, 2024
Merged

bjohansebas merged 1 commit into
masterfrom
be/use-negotiator

Conversation

@blakeembrey

@blakeembrey blakeembrey commented Oct 24, 2024 •

Copy link
Copy Markdown
Member

Follow up to #194 (comment).

Comment thread index.js
method = accept.encoding(['gzip', 'identity'])
}
var negotiator = new Negotiator(req)
var method = negotiator.encoding(['gzip', 'deflate', 'identity'], ['gzip'])

@blakeembrey blakeembrey Oct 24, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you add brotli, just add it here:

Suggested change
var method = negotiator.encoding(['gzip', 'deflate', 'identity'], ['gzip'])
var method = negotiator.encoding(hasBrotli ? ['br', 'gzip', 'deflate', 'identity'] : ['gzip', 'deflate', 'identity'], hasBrotli ? ['br', 'gzip'] : ['gzip'])

Edit: Could be better to store in global vars, e.g.

var SUPPORTED_ENCODING = hasBrotli ? ['br', 'gzip', 'deflate', 'identity'] : ['gzip', 'deflate', 'identity']; 
var PREFERRED_ENCODING = hasBrotli ? ['br', 'gzip'] : ['gzip'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants