You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Do not check content-type every time when appending response body - #3784
No actionable comments were generated in the recent review.
Walkthrough
Transaction now tracks whether response-body inspection is enabled. It sets this state from the configured MIME types and uses it to control response-body processing and buffering. Regression fixtures cover matching content types and the absence of a MIME filter.
Changes: Response body MIME inspection
Layer / File(s)
Summary
Set the response-body inspection flag headers/modsecurity/transaction.h, src/transaction.cc
Transaction adds and initializes an inspection flag. When a Content-Type header arrives, the code removes the value after the first semicolon and checks the lowercase type against the configured MIME types.
Gate response-body handling and verify MIME cases src/transaction.cc, test/test-cases/regression/config-response_type.json
processResponseBody and appendResponseBody return early when the flag is false. Regression fixtures cover a parameterized Content-Type, a missing Content-Type with no MIME filter, and the existing MIME filter cases.
owasp-modsecurity/ModSecurity#3664: Both changes update appendResponseBody gating to avoid buffering response data that will not be inspected.
Suggested labels:3.x
Suggested reviewers:airween, zimmerle
Merge Risk: Minimal · up to 9dac0
This change makes response-body handling cheaper by deciding once, when the Content-Type header arrives, whether the body needs inspection. Matching behavior is preserved, and new regression fixtures cover matching types, Content-Type parameters, and the no-filter case. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: the content-type check for response body appends is no longer repeated on each append. The change caches the inspection decision in transaction state when the Content-…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the content-type check for response body appends is no longer repeated on each append. The change caches the inspection decision in transaction state when the Content-Type header arrives, which matches the PR objectives and the summarized code changes in src/transaction.cc.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
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
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.
what
Content-Typeheader is received instead of repeatedly looking it up while processing body chunks.why
std::setlookups for every response-body chunk.Summary by CodeRabbit
Content-Typevalues that include parameters such as a character set.Content-Typeheader.