-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: add brotli to supported compression ποΈ #4503
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,23 @@ const Hoek = require('@hapi/hoek'); | |
|
||
|
||
const internals = { | ||
common: ['gzip, deflate', 'deflate, gzip', 'gzip', 'deflate', 'gzip, deflate, br'] | ||
common: ['gzip, deflate', 'deflate, gzip', 'gzip', 'deflate', 'br', 'gzip, deflate, br'] | ||
}; | ||
|
||
|
||
exports = module.exports = internals.Compression = class { | ||
|
||
decoders = { | ||
br: (options) => Zlib.createBrotliDecompress(options), | ||
gzip: (options) => Zlib.createGunzip(options), | ||
deflate: (options) => Zlib.createInflate(options) | ||
}; | ||
|
||
encodings = ['identity', 'gzip', 'deflate']; | ||
encodings = ['identity', 'gzip', 'deflate', 'br']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably appear before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, the order thingy should be addressed with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, the order should stay as is, bcos in current implementation |
||
|
||
encoders = { | ||
identity: null, | ||
br: (options) => Zlib.createBrotliCompress(options), | ||
gzip: (options) => Zlib.createGzip(options), | ||
deflate: (options) => Zlib.createDeflate(options) | ||
}; | ||
|
@@ -45,7 +47,6 @@ exports = module.exports = internals.Compression = class { | |
|
||
addEncoder(encoding, encoder) { | ||
|
||
Hoek.assert(this.encoders[encoding] === undefined, `Cannot override existing encoder for ${encoding}`); | ||
Hoek.assert(typeof encoder === 'function', `Invalid encoder function for ${encoding}`); | ||
this.encoders[encoding] = encoder; | ||
this.encodings.unshift(encoding); | ||
|
@@ -54,7 +55,6 @@ exports = module.exports = internals.Compression = class { | |
|
||
addDecoder(encoding, decoder) { | ||
|
||
Hoek.assert(this.decoders[encoding] === undefined, `Cannot override existing decoder for ${encoding}`); | ||
Hoek.assert(typeof decoder === 'function', `Invalid decoder function for ${encoding}`); | ||
this.decoders[encoding] = decoder; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This addition does not seem useful.
'br'
is quick to parse and I don't believe it is indeed a commonly used string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it worth to have it for consistency? π€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove
br
from commons, but by this logic it will make sense also to removegzip
,deflate
as well π€·