Skip to content
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

Charset content-type parameter in API responses #1808

Closed
DeD1rk opened this issue Jul 5, 2021 · 5 comments
Closed

Charset content-type parameter in API responses #1808

DeD1rk opened this issue Jul 5, 2021 · 5 comments
Assignees
Labels
api Issues related to the API feature Issues regarding a complete new feature priority: medium A new feature or a bugfix that is non-critical.

Comments

@DeD1rk
Copy link
Member

DeD1rk commented Jul 5, 2021

Is your feature request related to a problem? Please describe.

I'm always frustrated when the API doesn't specify the charset it uses.

Describe the solution you'd like

All API responses including their charset: content-type: application/json; charset=utf-8.

Motivation

That way we don't have to hardcode the charset in applications that use the API.

@DeD1rk DeD1rk added priority: medium A new feature or a bugfix that is non-critical. feature Issues regarding a complete new feature api Issues related to the API labels Jul 5, 2021
@se-bastiaan se-bastiaan self-assigned this Jul 5, 2021
@se-bastiaan
Copy link
Contributor

Apparently, the charset is not set on purpose: https://github.com/encode/django-rest-framework/blob/master/rest_framework/renderers.py#L68. So I am not sure what to do here. The API is completely following specifications.

Maybe it is possible to solve this in the app by using some middleware?

@se-bastiaan
Copy link
Contributor

More context: dart-lang/http#175

@DeD1rk
Copy link
Member Author

DeD1rk commented Jul 11, 2021

I see, interesting. I don't think there is any disadvantage in adding the charset anyway (since it is common practice), but I guess it would be quite a tough change. In the app I can simply decode everything before doing the json parsing, that is somewhat ugly and inefficient but not problematic.

@se-bastiaan
Copy link
Contributor

It doesn't really look like common practice, more like something people really can't seem to agree on. Imo the dart HTTP client should decode this as utf-8.

The cleanest solution is probably writing from wrapper around the existing HTTP code and transform the json correctly.

@DeD1rk
Copy link
Member Author

DeD1rk commented Jul 12, 2021

Agreed, I'll handle it in the app, and hope they find a real solution in dart/http sometime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API feature Issues regarding a complete new feature priority: medium A new feature or a bugfix that is non-critical.
Projects
None yet
Development

No branches or pull requests

2 participants