Skip to content

built-in mime type exclusion list - #98

Open
pavetheway91 wants to merge 1 commit into
kjdev:masterfrom
pavetheway91:built-in-mime-exclusions
Open

built-in mime type exclusion list#98
pavetheway91 wants to merge 1 commit into
kjdev:masterfrom
pavetheway91:built-in-mime-exclusions

Conversation

@pavetheway91

@pavetheway91 pavetheway91 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

same thing as kjdev/php-ext-zstd#104

Summary by CodeRabbit

  • New Features
    • Added built-in exclusions for commonly uncompressible media, image, font, archive, compression, and document MIME types.
    • Brotli compression now automatically skips these content types by default while supporting custom exclusions.
    • Module information now displays the built-in exclusion list.
  • Documentation
    • Clarified exact and wildcard MIME-type matching and how to extend default exclusions.
    • Updated configuration examples to combine multiple MIME types.
  • Tests
    • Expanded coverage for wildcard image-type exclusions, including SVG content.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 16ddd16f-1c2f-4446-b886-34f0d15848c9

📥 Commits

Reviewing files that changed from the base of the PR and between 2b76cba and 416ee17.

📒 Files selected for processing (6)
  • README.md
  • brotli.c
  • package.xml
  • php_brotli_mimetype_exclude.h
  • tests/ob_exclude_001.phpt
  • tests/ob_exclude_002.phpt
💤 Files with no reviewable changes (1)
  • tests/ob_exclude_001.phpt
🚧 Files skipped from review as they are similar to previous changes (5)
  • package.xml
  • php_brotli_mimetype_exclude.h
  • README.md
  • brotli.c
  • tests/ob_exclude_002.phpt

📝 Walkthrough

Walkthrough

The extension adds built-in MIME-type exclusions, checks them with configured exclusions before compression, reports them in module information, packages the new header, and updates documentation and output-buffer tests.

Changes

MIME exclusion handling

Layer / File(s) Summary
Runtime MIME exclusion checks
php_brotli_mimetype_exclude.h, brotli.c, package.xml
Defines built-in video, audio, image, font, PDF, archive, and compression exclusions. MIME matching checks both built-in and configured lists before compression. Module information reports the built-in list, and the package includes the new header.
Documentation and exclusion validation
README.md, tests/ob_exclude_001.phpt, tests/ob_exclude_002.phpt
Documents built-in exclusions and combined wildcard/exact matching. The tests cover built-in PDF and image-type exclusions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OutputHandler
  participant BuiltinExclusions
  participant ConfiguredExclusions
  OutputHandler->>BuiltinExclusions: Match response MIME type
  OutputHandler->>ConfiguredExclusions: Match response MIME type
  OutputHandler->>OutputHandler: Reject compression when either list matches
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a built-in MIME type exclusion list.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/ob_exclude_002.phpt (1)

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

Add or confirm independent coverage for built-in exclusions.

This test uses brotli.output_compression_exclude_types=image/*, so it exercises the configured wildcard list. Because image/svg is not in BROTLI_MIMETYPE_EXCLUDE, the test would still pass if the built-in exclusion check were removed. Add or confirm a case with an empty configured list and a built-in type such as image/png or application/pdf.

🤖 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_002.phpt` at line 17, Add an independent test case for
built-in MIME-type exclusions, using an empty
brotli.output_compression_exclude_types configuration and a built-in excluded
type such as image/png or application/pdf. Keep the existing wildcard-list
coverage in tests/ob_exclude_002.phpt, and ensure the new case verifies
exclusion without relying on the configured list.
🤖 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.

Inline comments:
In `@brotli.c`:
- Line 23: Add php_brotli_mimetype_exclude.h to package.xml as a source file
using the same package file-list section that contains php_brotli.h. Ensure the
header is included in PECL release contents so the include in brotli.c resolves
without a missing-file error.

---

Nitpick comments:
In `@tests/ob_exclude_002.phpt`:
- Line 17: Add an independent test case for built-in MIME-type exclusions, using
an empty brotli.output_compression_exclude_types configuration and a built-in
excluded type such as image/png or application/pdf. Keep the existing
wildcard-list coverage in tests/ob_exclude_002.phpt, and ensure the new case
verifies exclusion without relying on the configured list.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 520d4725-ce56-4a4f-9b2b-16ba6716756f

📥 Commits

Reviewing files that changed from the base of the PR and between 7f962d4 and d3528d3.

📒 Files selected for processing (5)
  • README.md
  • brotli.c
  • php_brotli_mimetype_exclude.h
  • tests/ob_exclude_001.phpt
  • tests/ob_exclude_002.phpt
💤 Files with no reviewable changes (1)
  • tests/ob_exclude_001.phpt

Comment thread brotli.c
@pavetheway91
pavetheway91 force-pushed the built-in-mime-exclusions branch 2 times, most recently from f6b8829 to 2b76cba Compare August 4, 2026 16:49
@pavetheway91
pavetheway91 force-pushed the built-in-mime-exclusions branch from 2b76cba to 416ee17 Compare August 4, 2026 16:51
@pavetheway91

Copy link
Copy Markdown
Contributor Author

brotli version of phpinfo improvements coming at some point during coming days

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