- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(response): avoid duplicated charset #2443
Conversation
This is not an acceptable solution. The You can do the following: response = Response()
response.headers['content-type'] = "text/plain;charset=UTF-8" |
@Kludex no problem. |
I think it's my bad. Hold on. 🙏 Thanks for the reference. I'll check this later. |
@Kludex thanks for the comments, have addressed them. I have additionally pushed a small change to the docs to clarify when the charset is set and when it is not set. |
1148cde
to
94de4d4
Compare
Summary
When populating the
media_type
with a MIME-type explicitly indcluding the; charset=
fortext/
MIME-types, Starlette would by default append an additional default; charset=utf-8
to the corresponding headers responseContent-Type
, which would result in a duplicatedcharset
.This PR introduces a check if either
; charset=
or;charset=
has already been included in themedia_type
to avoidcharset
being set twice.Before:
Response header Content-Type:
Content-Type: text/xml;charset=UTF-8; charset=utf-8
After:
Response header Content-Type:
Content-Type: text/xml;charset=UTF-8
Checklist