Skip to content

Replace accepts with negotiator - #197

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

Replace accepts with negotiator#197
bjohansebas merged 1 commit into
masterfrom
be/use-negotiator

Conversation

@blakeembrey

@blakeembreyblakeembrey commented Oct 24, 2024

Copy link
Copy Markdown
Member

Follow up to #194 (comment).

@blakeembreyblakeembrey mentioned this pull request Oct 24, 2024
Comment threadindex.js
method = accept.encoding(['gzip', 'identity'])
}
var negotiator = new Negotiator(req)
var method = negotiator.encoding(['gzip', 'deflate', 'identity'], ['gzip'])

@blakeembreyblakeembreyOct 24, 2024

Copy link
Copy Markdown
MemberAuthor

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
varmethod=negotiator.encoding(['gzip','deflate','identity'],['gzip'])
varmethod=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.

varSUPPORTED_ENCODING=hasBrotli ? ['br','gzip','deflate','identity'] : ['gzip','deflate','identity'];varPREFERRED_ENCODING=hasBrotli ? ['br','gzip'] : ['gzip'];

@bjohansebas
bjohansebas merged commit d3560e0 into masterOct 25, 2024
@blakeembrey
blakeembrey deleted the be/use-negotiator branch October 25, 2024 21:26
@jonchurchjonchurch mentioned this pull request Oct 26, 2024
@UlisesGasconUlisesGascon mentioned this pull request Oct 29, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@blakeembrey@bjohansebas