You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We have html, json, and text responses. We should automate setting of .conent_type attribute by reading from values of these attributes.
Describe the solution you'd like
If a user sets resp.text then the .content_type should be application/text. Likewise if resp.json has a value then the appropriate value can be set in .content_type for that.
Describe alternatives you've considered
We could follow starlette here and differentiate JSONResponse, HTMLResponse,... But these types distinctions are actually quite narrow. The HTMLResponse is just a Response with .media_type: str = "text/html". The JSONResponse on the other hand also adds a .render function that handles encoding.
On the other hand, httpx and request compatible APIs encode more in the top-level as enumerable string typed fields.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
We have html, json, and text responses. We should automate setting of
.conent_type
attribute by reading from values of these attributes.Describe the solution you'd like
If a user sets
resp.text
then the.content_type
should beapplication/text
. Likewise ifresp.json
has a value then the appropriate value can be set in.content_type
for that.Describe alternatives you've considered
.media_type: str = "text/html"
. The JSONResponse on the other hand also adds a.render
function that handles encoding.The text was updated successfully, but these errors were encountered: