Skip to content

feat(middleware): add text/xml and application/xml to default compressible types#1126

Closed
happysnaker wants to merge 1 commit into
go-chi:masterfrom
happysnaker:feat-compress-xml-types
Closed

feat(middleware): add text/xml and application/xml to default compressible types#1126
happysnaker wants to merge 1 commit into
go-chi:masterfrom
happysnaker:feat-compress-xml-types

Conversation

@happysnaker

Copy link
Copy Markdown
Contributor

Summary

Fixes #920

XML content compresses very effectively (typically 70-90% reduction) and is commonly served by web applications, APIs, and RSS/Atom feeds. This adds text/xml and application/xml to the default compressible content types list.

Note that application/atom+xml and application/rss+xml were already in the list — but generic XML was not.

Changes

  • Added application/xml and text/xml to defaultCompressibleContentTypes

…sible types

XML content compresses very effectively and is commonly served
by web applications. This adds text/xml and application/xml to
the default compressible content types list.

Fixes go-chi#920

@VojtechVitek VojtechVitek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@VojtechVitek VojtechVitek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The tests don't pass:

--- FAIL: TestCompressorWildcards (0.01s)
--- FAIL: TestCompressorWildcards/defaults (0.00s)
--- PASS: TestCompressorWildcards/no_wildcard (0.01s)
--- PASS: TestCompressorWildcards/invalid_wildcard_#1 (0.00s)
--- PASS: TestCompressorWildcards/invalid_wildcard_#2 (0.00s)
--- PASS: TestCompressorWildcards/valid_wildcard (0.00s)
--- PASS: TestCompressorWildcards/mixed (0.00s)

VojtechVitek added a commit that referenced this pull request Jul 3, 2026
PR #1126 added application/xml and text/xml to
defaultCompressibleContentTypes but did not update the
TestCompressorWildcards/defaults assertion, which hardcoded the
expected count at 10. Derive it from len(defaultCompressibleContentTypes)
instead so the test stays correct as defaults are added or removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
VojtechVitek added a commit that referenced this pull request Jul 3, 2026
…sible types (#1127)

* feat(middleware): add text/xml and application/xml to default compressible types

XML content compresses very effectively and is commonly served
by web applications. This adds text/xml and application/xml to
the default compressible content types list.

Fixes #920

* test(middleware): derive default compressible types count from the slice

PR #1126 added application/xml and text/xml to
defaultCompressibleContentTypes but did not update the
TestCompressorWildcards/defaults assertion, which hardcoded the
expected count at 10. Derive it from len(defaultCompressibleContentTypes)
instead so the test stays correct as defaults are added or removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: happysnaker <73147033+happysnaker@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@VojtechVitek

Copy link
Copy Markdown
Contributor

Merged via #1127. Thank you 🎉

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.

middleware.Compress should by default compress text/xml, application/xml, and arguably text/*

2 participants