Add optional charset parameter to web.FileResponse - #13151
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13151 +/- ##
=======================================
Coverage 99.01% 99.01%
=======================================
Files 132 132
Lines 49813 49845 +32
Branches 2587 2588 +1
=======================================
+ Hits 49323 49355 +32
Misses 368 368
Partials 122 122
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
@aiolibsbot review |
PR Review — Add optional charset parameter to web.FileResponseClean, well-scoped addition of an optional Strengths:
🟢 Suggestions
1. `charset` silently ignored for non-`text/` text-based media types
|
Yeah, this is what was standing out to me as a bit odd. I'm not sure this is the right design. I'm also wondering about getting the charset automatically.. |
Allows callers to set an explicit charset on the Content-Type header for text-like MIME types (e.g. text/plain, text/html). Fixes aio-libs#4559
093f651 to
8997395
Compare
Confidence Score: 4/5The implementation appears safe to merge after the non-blocking repository documentation and changelog requirements are addressed. The new charset behavior has focused functional coverage and no concrete runtime defect was established, but the public API addition lacks its required threat-model update and the changelog fragment lacks attribution. Files Needing Attention: aiohttp/web_fileresponse.py, CHANGES/4559.feature.rst Reviews (1): Last reviewed commit: "Add optional charset parameter to web.Fi..." | Re-trigger Greptile |
| status: int = 200, | ||
| reason: str | None = None, | ||
| headers: LooseHeaders | None = None, | ||
| charset: str | None = None, |
There was a problem hiding this comment.
Adding charset to the public FileResponse constructor requires the corresponding THREAT_MODEL.md update, while the feature fragment also needs the repository-required -- by :user: attribution; leaving both out makes the security documentation and release metadata incomplete for this API.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Fixes #4559
Adds an optional
charsetparameter toweb.FileResponseso callers can set an explicit charset on the response content-type.