Skip to content

Feat mime type exclusions#101

Merged
kjdev merged 3 commits into
masterfrom
feat/mime-type-exclusions
Jul 2, 2026
Merged

Feat mime type exclusions#101
kjdev merged 3 commits into
masterfrom
feat/mime-type-exclusions

Conversation

@kjdev

@kjdev kjdev commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a new output-compression setting to exclude specific MIME types from zstd compression.
    • Supports both exact matches and wildcard patterns like image/*.
  • Bug Fixes

    • Responses with excluded content types now stay uncompressed, including cases with charset parameters.
    • Compression still applies when the response type does not match the exclusion list.
  • Documentation

    • Updated the README with the new configuration option and usage details.
  • Tests

    • Added coverage for exact matches, wildcard matching, charset handling, and non-matching content types.

kjdev added 3 commits July 2, 2026 10:17
Allow excluding responses with specific MIME types (exact match or
wildcard subtype) from transparent output compression via
zstd.output_compression_exclude_types.
Cover exact match, wildcard match, match with a charset parameter,
and the no-match case where compression still applies.
Add the option to the configuration table and describe its matching
rules.
@coderabbitai

coderabbitai Bot commented Jul 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

Run ID: 9e67429d-3218-4d69-9eed-5a1d2308ea32

📥 Commits

Reviewing files that changed from the base of the PR and between dc7602c and d8c8b61.

📒 Files selected for processing (7)
  • README.md
  • php_zstd.h
  • tests/ob_exclude_001.phpt
  • tests/ob_exclude_002.phpt
  • tests/ob_exclude_003.phpt
  • tests/ob_exclude_004.phpt
  • zstd.c

📝 Walkthrough

Walkthrough

Adds a new zstd.output_compression_exclude_types INI setting and module global to exclude specific MIME types from zstd output compression. Implements exact and wildcard matching logic in the output handler, integrates an early exclusion check, adds PHPT tests, and updates README documentation.

Changes

Output compression MIME exclusion

Layer / File(s) Summary
Global field and INI declaration
php_zstd.h, zstd.c
Adds output_compression_exclude_types global field and registers the zstd.output_compression_exclude_types INI entry with OnUpdateString.
MIME exclusion matching and handler integration
zstd.c
Adds php_zstd_output_mimetype_excluded() supporting exact and type/* wildcard matches, and calls it early in php_zstd_output_handler() during PHP_OUTPUT_HANDLER_START to skip compression when matched.
Exclusion behavior tests
tests/ob_exclude_001.phpt, tests/ob_exclude_002.phpt, tests/ob_exclude_003.phpt, tests/ob_exclude_004.phpt
Adds PHPT tests for exact match, wildcard match, charset-inclusive match, and confirmation that non-matching types are still compressed.
README documentation updates
README.md
Updates the output handler option table and adds descriptive text for the new exclusion setting.

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

Sequence Diagram(s)

sequenceDiagram
  participant PHPScript
  participant OutputHandler as php_zstd_output_handler
  participant MimeChecker as php_zstd_output_mimetype_excluded
  PHPScript->>OutputHandler: emit response with Content-Type
  OutputHandler->>MimeChecker: check exclude_types against mimetype
  MimeChecker-->>OutputHandler: excluded or not
  OutputHandler-->>PHPScript: FAILURE (skip compression) or continue compression
Loading
🚥 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 is concise and accurately reflects the new MIME type exclusion feature added by the change set.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mime-type-exclusions

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.

@kjdev kjdev merged commit dbcb051 into master Jul 2, 2026
157 checks passed
@kjdev kjdev deleted the feat/mime-type-exclusions branch July 2, 2026 01:32
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