-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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(server): Add support for encoded source files #3123
feat(server): Add support for encoded source files #3123
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
CLA signed |
CLAs look good, thanks! |
1ac7de8
to
720d718
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.
You mentioned pushback, can you point to it so I can understand the issue. Your approach looks good to me.
Can you add a short bit of documentation to dev/plugins.html under preprocessors?
I'm thinking of a slight re-write of your commit description:
a preprocessor encodes the contents and stores them in the File class' new encodings property. The encodings property is a keyed object where the keys are the encoding type ('gzip', 'compress', 'br', etc.) and the values are the encoded content.
I updated the description and added a link to [the issue](This #1241) in which there was pushback. |
720d718
to
47f2305
Compare
Done. It felt odd to document only the |
554b550
to
0e0d5ad
Compare
0e0d5ad
to
3bcb162
Compare
I think your feature is more general than the feature request that was rejected earlier. It fits into karma's architecture, allowing other plugins without a large impact on the core code. |
This change allows preprocessors to specify an encoding for files. Currently, if a preprocessor encodes a file in a format such as gzip or Brotli, the file is served with the wrong encoding. The only workaround for this is to also include a plugin (example) that removes encoded files from
files.served
and serves them manually using a custom file handler. This approach is a gross hack that unnecessarily complicates the encoding plugin's logic.With this change, a preprocessor encodes the contents and stores them in the File class' new
encodings
property. Theencodings
property is a keyed object where the keys are the encoding type ('gzip', 'compress', 'br', etc.) and the values are the encoded content. This pattern has the advantage of allowing multiple encoders and serving the encoding that best matches the request. It also allows the unencoded content to be served, when no encoding matches the request.I know there has been pushback on adding encoding support, but I'm hoping this approach is an acceptable compromise. This solution leaves pretty much all encoding logic to the preprocessors and minimizes karma's role as much as possible.