Add exclude_content_types parameter to GZipMiddleware - #3418
Merged
Merged
Conversation
Contributor
|
Docs preview: https://6f48e5f7-starlette.marcelotryle.workers.dev |
Kludex
commented
Aug 6, 2026
| from starlette.datastructures import Headers, MutableHeaders | ||
| from starlette.types import ASGIApp, Message, Receive, Scope, Send | ||
|
|
||
| DEFAULT_EXCLUDED_CONTENT_TYPES = ("text/event-stream",) |
Owner
Author
There was a problem hiding this comment.
The "EXCLUDED" was a mistake.
It should have been exclude.
Kludex
enabled auto-merge (squash)
August 6, 2026 19:37
Kludex
disabled auto-merge
August 6, 2026 19:42
Kludex
enabled auto-merge (squash)
August 6, 2026 20:32
Kludex
disabled auto-merge
August 6, 2026 20:33
Merged
3 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add a keyword-only
exclude_content_typesparameter toGZipMiddleware, replacing the hardcoded exclusion check.Content-Typemedia type equals an entry, or matches atype/*wildcard entry (e.g."image/*"). Matching is case-insensitive and ignores parameters likecharset; configured values are normalized the same way.DEFAULT_EXCLUDED_CONTENT_TYPES(("text/event-stream",)), which stays importable so the defaults can be extended rather than replaced.thread_minimum_sizeinGZipResponder#3415).Supersedes #3091 and #3040, and implements the feature requested in #3414.
Wire-visible deltas from the previous prefix check, for the release notes: matching is now case-insensitive,
text/event-stream-foono longer matches, and reassigningDEFAULT_EXCLUDED_CONTENT_TYPESat runtime no longer takes effect (the exclusions are read at construction).AI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.