Skip to content

Conversation

@achille-roussel
Copy link
Contributor

I observed content encoding negotiation issues that I believe was caused by the connect-python client having a hardcoded list of supported encodings despite not necessarily having the corresponding modules loaded. This PR should address it by generating the default Accept-Encoding header based on what the client supports, as detected dynamically at run time.

…e client

Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
Copy link
Collaborator

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Thanks! This indeed looks like a bug

This excludes 'identity' since it's an implicit fallback, and returns
only compressions that are actually available (i.e., their dependencies are installed).
"""
preferred_order = ["gzip", "br", "zstd"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's move this out of the function, maybe DEFAULT_ACCEPT_ENCODING_COMPRESSIONS

only compressions that are actually available (i.e., their dependencies are installed).
"""
preferred_order = ["gzip", "br", "zstd"]
return [name for name in preferred_order if name in _compressions]
Copy link
Collaborator

@anuraaga anuraaga Dec 24, 2025

Choose a reason for hiding this comment

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

What do you think about returning the joined string without the intermediate list? A microoptimization, but the list is only benefiting the unit test currently IIUC

Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
@achille-roussel
Copy link
Contributor Author

Thanks for the review @anuraaga, I addressed your feedback!

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
@anuraaga anuraaga changed the title set default accept-encoding to compression algorithms supported by the client Set default accept-encoding to compression algorithms supported by the client Dec 25, 2025
@anuraaga anuraaga merged commit 84c3529 into connectrpc:main Dec 25, 2025
35 of 41 checks passed
@anuraaga
Copy link
Collaborator

Thanks as always @achille-roussel - will see how it goes with the holidays but will try to get this released soon

@anuraaga anuraaga added the bug Something isn't working label Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants