-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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(ext/http): auto-compression of fixed response bodies #13769
Conversation
7f4f84c
to
304409e
Compare
Co-authored-by: Ryan Dahl <[email protected]> Co-authored-by: Satya Rohith <[email protected]>
304409e
to
371e557
Compare
Co-authored-by: Luca Casonato <[email protected]>
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 is looking great! @kitsonk what do you think about adding an option to disable this behaviour to a Deno.serveHttp
options bag?
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.
Also do we need to have special handling for Range
?
I thought about it when I paired with @ry and he argued against it. It does add complexity to it. Is there a compelling case where someone would want to disable it, other than "because they can"? Doesn't setting |
I could imagine that one has an nginx in front of Deno that is responsible for on the fly encoding. In that case you want Deno to leave the responses as "pure" as possible. I don't think we per-se need to add this for the PR to land, but I think it would be useful to give users an opt-out. The implementation complexity seems rather trivial. |
Actually, after doing a bit of research, if a |
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
@satyarohith PTAL too
|
||
// Data obtained from https://github.com/jshttp/mime-db/blob/fa5e4ef3cc8907ec3c5ec5b85af0c63d7059a5cd/db.json | ||
// Important! Keep this list sorted alphabetically. | ||
const CONTENT_TYPES: &[&str] = &[ |
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.
Nit: there are some new additions to https://github.com/jshttp/mime-db/blob/master/db.json; we might want to update the list.
feel free to skip it
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.
Let's skip it for now, as they are very likely very esoteric media types that aren't widely used.
Longer term, someone should either find an efficient way to statically include the JSON in, or generate the code statically from the JSON file.
Co-authored-by: Satya Rohith <[email protected]>
Co-authored-by: Satya Rohith <[email protected]>
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.
Thanks for working on it! :)
Work in progress from a pairing session between myself and @ry
Inspired by previous work of @satyarohith on Deno Deploy.