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

Enhance req.acceptsEncodings #6086

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

Conversation

Abdel-Monaam-Aouini
Copy link

@Abdel-Monaam-Aouini Abdel-Monaam-Aouini commented Oct 25, 2024

Enhance req.acceptsEncodings Method

This enhancement refines the req.acceptsEncodings method to improve the handling of the request's Accept-Encoding header. The updated method checks whether the client accepts the specified encoding(s) and returns the best matching encoding or an array of acceptable encodings.

Key Features:

  • Supports single or multiple encoding strings and a comma-delimited list of encodings.
  • Provides consistent behavior across different input formats.
  • Enhances code readability and maintainability.

Examples:

  • req.acceptsEncodings('gzip') returns "gzip" when the Accept-Encoding header includes "gzip".
  • req.acceptsEncodings('br') returns false if the encoding isn't accepted by the client.
  • req.acceptsEncodings('gzip, deflate') returns "gzip" as the best match.

This update ensures more robust handling of accepted encodings, improving compatibility and performance.

Copy link
Member

@wesleytodd wesleytodd left a comment

Choose a reason for hiding this comment

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

Same as the comment in #6139. This PR is quite a bit more robust, so it is also something we will need to compare, but before we merge either of these we need to have a quick perf review of these kinds of changes.

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

Successfully merging this pull request may close these issues.

2 participants