You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.
When using https://github.com/kanongil/brok to enable brotli compression the plugin registers a new encoding br that gets pushed to the end of the encoding array here: https://github.com/hapijs/hapi/blob/master/lib/compression.js#L52.
Therefor hapijs/accept gets the encoding with br at the last position and thus always prefers gzip over br if no explicit weights are defined in the accept-encoding header. Chrome and Firefox (and maybe others) send gzip, deflate, br. So they never get served brotli encoded content.
I would work on a PR but would like to get some guidance first.
I see these ideas, there are for sure others that are probably better:
exposing server.sortEncodings taking a function used to sort the encodings with Array.sort. This does not seem to be a good solution as it widens the API of server.
Any other ideas and guidance on how to implement this are very much appreciated.
The text was updated successfully, but these errors were encountered:
Setting a priority is probably something that should be configurable on the server, or maybe even at the route level. Ie, option 1 & 2 won't work.
As for option 3, I don't think it is the right approach. A rework of the route.options.compression setting should work better. For example allow the option to be an array which implies the preferred order:
When using https://github.com/kanongil/brok to enable brotli compression the plugin registers a new encoding
br
that gets pushed to the end of theencoding
array here: https://github.com/hapijs/hapi/blob/master/lib/compression.js#L52.Therefor hapijs/accept gets the encoding with
br
at the last position and thus always prefersgzip
overbr
if no explicit weights are defined in theaccept-encoding
header. Chrome and Firefox (and maybe others) sendgzip, deflate, br
. So they never get served brotli encoded content.I would work on a PR but would like to get some guidance first.
I see these ideas, there are for sure others that are probably better:
accept a third parameter on
server.encoder
with a priority. the default priority for all internal encodings could be 0.5. The encodings then get sorted by this value here: https://github.com/hapijs/hapi/blob/master/lib/compression.js#L40.instead of
this.encodings.push
usethis.encodings.unshift
to add new encodings here: https://github.com/hapijs/hapi/blob/master/lib/compression.js#L52. This would lead to all user added encodings being preferred over the Hapi internal ones.exposing server.sortEncodings taking a function used to sort the encodings with
Array.sort
. This does not seem to be a good solution as it widens the API of server.Any other ideas and guidance on how to implement this are very much appreciated.
The text was updated successfully, but these errors were encountered: