-
-
Notifications
You must be signed in to change notification settings - Fork 238
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: don't compress on x-no-compression header #208
base: master
Are you sure you want to change the base?
Conversation
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.
function shouldCompress (req, res) {
var type = res.getHeader('Content-Type')
var noCompressionHeader = res.getHeader('x-no-compression')
if (noCompressionHeader) {
debug('%s not compressed', type)
return false
}
if (type === undefined || !compressible(type)) {
debug('%s not compressible', type)
return false
}
return true
}
PS: I don't know why but I am not seeing the commit suggestion feature right now, so I have given the code in comment.
7a4b75e
to
79cdf57
Compare
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.
LGTM
we shouldn't hardcode tbis behavior. x-no-compression is not a standard http header. the readme already has an example of how to do this within application code |
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.
see above comment
For those looking for the doc referenced above: https://github.com/expressjs/compression?tab=readme-ov-file#filter-1 How do we feel about adding an option for this? While I agree we should not hard code this non-standard behavior, it is quite common for libraries and proxies to implement handling for commonly used non-standard headers. This one feels to me like a reasonable one to support in that way. |
We should observe when
X-No-Compression
is sent in the request.