Skip to content
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: support brotli #150

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

feat: support brotli #150

wants to merge 5 commits into from

Conversation

clarkdo
Copy link

@clarkdo clarkdo commented Jan 18, 2019

No description provided.

Copy link
Contributor

@dougwilson dougwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for volunteering to help get this feature a reality! From reviewing the PR, it looks like the following things still need to be done, so I'm listing so you have something concrete to work through:

(1) There is no documentation around this, specifically all the options like chunkSize, level, memLebel, stragety, windowBits, etc. are all using zlib constants and not the Brotli constants. I have not actually looked hard yet, but I assume these constants are not the right ones for Brotli (since the Node.js doc lists different constants) but at worse since all these constants are just integers, setting one of these options may break when br is accepted by the client, since they are going to be passed into createBrotliDecompress with this PR (this needs to be validated / tested).

(2) There are no tests added. This is picked up just by the coverage CI check, since the new line for br in the switch statement is not getting triggered, but there should be at least all the equiv tests for br that there are for the others.

I hope this helps! Thanks for picking this up!

README.md Outdated Show resolved Hide resolved
@clarkdo
Copy link
Author

clarkdo commented Jan 18, 2019

@dougwilson Thank you so much for the quick and detailed review.

For the options, which solution do you think is better ?

  1. Try to match current options into brotli options for keeping consistency, this may be harder and risky since the zlip api are very different between zlib-based and brotli based.
  2. Add a new brotli options field(maybe options.brotli) in options of compression and add doc (the same way as node is doing now)

For the test, since brotli is only supported in node 11.7, can we add it in travis ?

@manniL

This comment has been minimized.

Copy link

@cecchi cecchi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @clarkdo!

For what it's worth, in my testing the content negotiation provided by accepts (which uses negotiator under the hood) will choose gzip over br for most popular browsers. There's an issue tracking that behavior here: jshttp/negotiator#49

Working off of your branch I was able to get Brotli working end-to-end by swapping out the content negotiation from "accepts" to "accept": https://www.npmjs.com/package/accept, and fixing a couple typos.

I'm happy to contribute those changes if we want to prefer br over gzip. The changelist is visible here: deal#1

index.js Outdated Show resolved Hide resolved
@svewag

This comment has been minimized.

@Saiv46

This comment has been minimized.

1 similar comment
@jeremytenjo

This comment has been minimized.

@HamzaAnis

This comment has been minimized.

@Saiv46

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants