Switch encoding preference from client controlled to server#322
Open
anuraaga wants to merge 2 commits intoconnectrpc:mainfrom
Open
Switch encoding preference from client controlled to server#322anuraaga wants to merge 2 commits intoconnectrpc:mainfrom
anuraaga wants to merge 2 commits intoconnectrpc:mainfrom
Conversation
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
|
@anuraaga is attempting to deploy a commit to the connectrpc Team on Vercel. A member of the Team first needs to authorize it. |
| If a user configures a server with an ordered list of encodings, it should be compared | ||
| in order to client's **Accept-Encoding** to determine the encoding for a response. | ||
| If the client uses an unsupported **Content-Encoding**, servers should return an | ||
| error with code "unimplemented" and a message listing the supported encodings. |
There was a problem hiding this comment.
could it be helpful or appropriate to add an example of both sides configuration and which wins? This might underscore the conflict that led to this PR
Contributor
Author
There was a problem hiding this comment.
Sounds good, added some. If they seem too noisy, can cut down or remove them anyways, works either way for me
Contributor
Author
|
Thanks @thezachdrake @timostamm for the discussion on #319. Wondering if we can continue here, to hopefully make a change here, or decide not to if it seems like too much. Happy to hear any thoughts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #319
Currently, the preference of encoding is based on the client's
accept-encoding. This unfortunately leaves connect-web generally unable to use modern compression schemes because the header is set by the browser, which always starts withgzip(i.e.Accept-Encoding: gzip, deflate, br, zstd). It also differs in behavior from common servers like Envoy, nginx, Apache, which all use the order of encodings configured on the server for preference instead of the accept-encoding, for equal quality values.This PR proposes to align behavior with those servers, by making the order configured on the server the encoding preference, not client. If server is configured as
[zstd, br, gzip], a browser would finally be able to usebrorzstd.Compatibility note - I was hoping the Go, Python, Node all behaved the same with only supporting gzip by default. But I found Node supports gzip and br by default
https://github.com/connectrpc/connect-es/blob/main/packages/connect-express/src/express-connect-middleware.ts#L69
This means, this spec change will actually be a breaking change there, since a connect-node (not connect-web) client configured to send
br, gzipand a default server will switch frombrtogzip. I was hoping we'd be able to get through this without breaking change worries, so this definitely makes me less convinced by the proposal. At the same time, since I suspect using both connect-node and connect-web is a common pattern, connect-node stands to benefit the most from this change to improve compression from the browser. Curious to hear thoughts on that.connect-go defaults to only gzip, though it also technically accepts compressions as an ordered list of
Option. They're currently merged into an unordered map, but if making it actually ordered, it may also be considered a breaking change in behavior, though with the gzip-only default I think the impact is lower there.Anyways, let me know any thoughts. Thanks!