Skip to content

Compressor content-type wildcard support - #46374

Closed
Vexali0n wants to merge 0 commit into
envoyproxy:mainfrom
Vexali0n:main
Closed

Compressor content-type wildcard support#46374
Vexali0n wants to merge 0 commit into
envoyproxy:mainfrom
Vexali0n:main

Conversation

@Vexali0n

Copy link
Copy Markdown

Commit Message:
This PR enhances current functionality of the compressor module to allow wildcards for the content type list.

Additional Description:
Current state of compressor allows only to use exact match for content types or it will fallback to the default list. There is no way how to specify wildcards to allow extreme amount of different content types as it is in our case. Generative AI has been used.

Risk Level:
Medium

Testing:
In addition to the written tests in the PR I have compiled the proxy locally, started up the proxy and tested against multiple envoy proxy configurations to prove wildcards are supported and response is compressed while original logic of exact match and default list still function correctly.

Docs Changes:
Only 1 comment inside the compressor.proto file

Release Notes:
compressor: added support for wildcards (such as text/* or *) in the compressor filter's content_type configuration to allow matching MIME type prefixes or all content types.

[Optional Fixes #Issue]
Fixes #46344

@repokitteh-read-only

Copy link
Copy Markdown

Hi @Vexali0n, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #46374 was opened by Vexali0n.

see: more, trace.

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #46374 was opened by Vexali0n.

see: more, trace.

@markdroth

Copy link
Copy Markdown
Contributor

/lgtm api

@wbpcode wbpcode left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution.

Comment on lines +128 to +141
for (const auto& type : types) {
std::string trimmed = std::string(StringUtil::trim(type));
if (trimmed.empty()) {
continue;
}
if (trimmed == "*" || trimmed == "*/*") {
has_global_wildcard = true;
} else if (absl::EndsWith(trimmed, "/*")) {
std::string prefix = std::string(absl::StripSuffix(trimmed, "*"));
prefix_patterns.push_back(absl::AsciiStrToLower(prefix));
} else {
exact_set.insert(absl::AsciiStrToLower(trimmed));
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FWIW, this is a behavior change. For example, in the previous implementation, custom/* will be treated as an exact content type and in the new implementation, this will be treated as an prefix.

I will inclined to add a repeated type.matcher.v3.StringMatcher content_type_matcher rather than changing the meaning of existing API.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback. You are right I haven't thought that somebody would actually configure in their configs wildcard while using exact match.

I am gonna rewrite it to still fully support old behavior the way you have mentioned.

@Vexali0n

Copy link
Copy Markdown
Author

FYI: This PR was closed and reopened with funcionality that was suggested by @wbpcode

New PR: #46458

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.

Compression Content Types

4 participants