-
- Notifications
You must be signed in to change notification settings - Fork 240
feat: add default option #191
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
Changes from all commits
c87d82f b1644d9 7b58257 5d6a827 24609a6 86d65a9 7a3f9ef 66c0cb7 7e00d42 d4d6722 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 | ||||||
|---|---|---|---|---|---|---|---|---|
| | @@ -37,6 +37,8 @@ module.exports.filter = shouldCompress | |||||||
| | ||||||||
| var cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/ | ||||||||
| | ||||||||
| var encodingSupported = ['*', 'gzip', 'deflate', 'identity'] | ||||||||
| | ||||||||
| /** | ||||||||
| * Compress response data with gzip / deflate. | ||||||||
| * | ||||||||
| | @@ -51,6 +53,7 @@ function compression (options) { | |||||||
| // options | ||||||||
| var filter = opts.filter || shouldCompress | ||||||||
| var threshold = bytes.parse(opts.threshold) | ||||||||
| var enforceEncoding = opts.enforceEncoding || 'identity' | ||||||||
| | ||||||||
| if (threshold == null) { | ||||||||
| threshold = 1024 | ||||||||
| | @@ -177,6 +180,11 @@ function compression (options) { | |||||||
| var negotiator = new Negotiator(req) | ||||||||
| var method = negotiator.encoding(['gzip', 'deflate', 'identity'], ['gzip']) | ||||||||
| | ||||||||
| // if no method is found, use the default encoding | ||||||||
| if (!req.headers['accept-encoding'] && encodingSupported.indexOf(enforceEncoding) !== -1) { | ||||||||
| method = enforceEncoding === '*' ? 'gzip' : enforceEncoding | ||||||||
| Member 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. I dont see Member Author 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. If * is not checked and changed, the deflate encoding would be applied as it’s the last one in the check ( Lines 196 to 198 in 66c0cb7
Member 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. Sorry but I don't follow your description? To me it looks like this value for the option (coming from the calling code) could just be dropped entirely. Member Author 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. I haven't found a way to eliminate this check. | ||||||||
| } | ||||||||
| | ||||||||
| // negotiation failed | ||||||||
| if (!method || method === 'identity') { | ||||||||
| nocompress('not acceptable') | ||||||||
| | ||||||||
Uh oh!
There was an error while loading. Please reload this page.