Skip to content

Feat mimetype exclude negation tokens - #102

Merged
kjdev merged 3 commits into
masterfrom
feat/mimetype-exclude-negation-tokens
Aug 13, 2026
Merged

Feat mimetype exclude negation tokens#102
kjdev merged 3 commits into
masterfrom
feat/mimetype-exclude-negation-tokens

Conversation

@kjdev

@kjdev kjdev commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added support for negated MIME-type tokens in Brotli output compression exclusions.
    • Supports exact matches, wildcards, quoted ! tokens, and last-match precedence.
    • Configured exclusions fall back to the built-in exclusion list when no token matches.
  • Bug Fixes

    • Corrected handling of PNG responses so compression behavior follows configured inclusion and exclusion rules.
  • Documentation

    • Documented the expanded MIME-type matching behavior and precedence rules.

kjdev added 3 commits August 13, 2026 09:43
A token prefixed with `!` negates a match against the built-in MIME
exclusion list, allowing individual entries to be re-enabled for
compression. Within the same list, when multiple tokens match the
same MIME type, the last one listed wins, positive or negative
(gitignore-style precedence). The built-in list is only consulted as
a fallback when the user-configured list produces no definitive
match.
Cover the default built-in exclusion, overriding it with a negation
token, and the last-matching-token-wins precedence when a positive
and a negative token in the same list both match, in either order.
Explain the `!` token for re-enabling individual entries from the
built-in exclusion list, and the last-match-wins precedence rule
(gitignore-style: later tokens in the same list override earlier
ones, whether positive or negative).
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Brotli MIME exclusion matching now supports negated tokens, exact and wildcard matches, last-match precedence, and fallback to built-in exclusions. CGI tests cover default exclusions and override behavior. The README documents the new configuration rules.

Changes

MIME exclusion matching

Layer / File(s) Summary
Matcher and output-handler integration
brotli.c
The MIME matcher returns positive, negative, or no-match results. It supports exact and wildcard tokens, negation, and last-match precedence. The output handler falls back to built-in exclusions when configured tokens do not match.
Behavior validation and documentation
tests/ob_exclude_00*.phpt, README.md
CGI tests cover default exclusions, negated exclusions, later matching tokens, and wildcard overrides. The README documents token quoting and precedence rules.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to 2ca95

The remaining concerns are limited to optional coverage for negated wildcard and nonmatching MIME-type cases; no actionable merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant BrotliOutputHandler
  participant ConfiguredMimeMatcher
  participant BuiltInExclusionList
  participant HTTPResponse
  BrotliOutputHandler->>ConfiguredMimeMatcher: Evaluate configured MIME tokens
  ConfiguredMimeMatcher-->>BrotliOutputHandler: Return match status
  alt No configured token matches
    BrotliOutputHandler->>BuiltInExclusionList: Check built-in exclusions
    BuiltInExclusionList-->>BrotliOutputHandler: Return exclusion status
  end
  BrotliOutputHandler->>HTTPResponse: Compress or exclude response
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: support for negation tokens in MIME-type exclusions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mimetype-exclude-negation-tokens

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/ob_exclude_006.phpt (1)

10-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a negated wildcard test.

This test covers exact negation only. Add a CGI PHPT case with brotli.output_compression_exclude_types="!image/*" and Content-Type: image/png. Expect Brotli output.

This verifies the documented negated wildcard path independently from the exact-token cases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/ob_exclude_006.phpt` around lines 10 - 24, Add a separate CGI PHPT test
based on tests/ob_exclude_006.phpt that sets
brotli.output_compression_exclude_types to "!image/*" while retaining
Content-Type image/png and HTTP_ACCEPT_ENCODING=br. Expect Brotli-compressed
output using the existing files/ob_hi.br fixture and the same Content-Encoding
and Vary headers.
tests/ob_exclude_005.phpt (1)

10-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a configured no-match fallback test.

This test covers an empty configured list. It does not cover the new fallback path for a nonempty list with no matching token.

Add a CGI PHPT case with brotli.output_compression_exclude_types="application/json" and Content-Type: image/png. Expect uncompressed output. This verifies that the built-in exclusion still applies after configured matching returns no match.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/ob_exclude_005.phpt` around lines 10 - 20, Add a separate CGI PHPT test
covering a nonempty exclusion list with no matching token: configure
brotli.output_compression_exclude_types as application/json, send Content-Type
image/png with Brotli accepted, and assert uncompressed output. Keep the test
focused on verifying the built-in exclusion fallback after configured matching
finds no match.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/ob_exclude_005.phpt`:
- Around line 10-20: Add a separate CGI PHPT test covering a nonempty exclusion
list with no matching token: configure brotli.output_compression_exclude_types
as application/json, send Content-Type image/png with Brotli accepted, and
assert uncompressed output. Keep the test focused on verifying the built-in
exclusion fallback after configured matching finds no match.

In `@tests/ob_exclude_006.phpt`:
- Around line 10-24: Add a separate CGI PHPT test based on
tests/ob_exclude_006.phpt that sets brotli.output_compression_exclude_types to
"!image/*" while retaining Content-Type image/png and HTTP_ACCEPT_ENCODING=br.
Expect Brotli-compressed output using the existing files/ob_hi.br fixture and
the same Content-Encoding and Vary headers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 616cd7bb-f5be-40e1-8988-413ec02258cf

📥 Commits

Reviewing files that changed from the base of the PR and between f2c0ff7 and 2ca9526.

📒 Files selected for processing (6)
  • README.md
  • brotli.c
  • tests/ob_exclude_005.phpt
  • tests/ob_exclude_006.phpt
  • tests/ob_exclude_007.phpt
  • tests/ob_exclude_008.phpt

@kjdev
kjdev merged commit 2ca9526 into master Aug 13, 2026
254 of 325 checks passed
@kjdev
kjdev deleted the feat/mimetype-exclude-negation-tokens branch August 13, 2026 01:57
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.

1 participant