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

Rejects application/json; charset=utf-8 #157

Closed
coolaj86 opened this issue Oct 17, 2018 · 1 comment
Closed

Rejects application/json; charset=utf-8 #157

coolaj86 opened this issue Oct 17, 2018 · 1 comment

Comments

@coolaj86
Copy link

When making a request with window.fetch the default Content-Type is application/json; charset=utf-8:

window.fetch("/foo", {
  method: 'POST'
, body: JSON.stringify(data)
});
Content-Type: application/json; charset=utf-8

Macaron returns an error:

[{"classification":"ContentTypeError","message":"Unsupported Content-Type"}]

I expect instead that it should handle the json the same as it does without the utf-8:

window.fetch("/foo", {
  method: 'POST'
, body: JSON.stringify(data)
, headers: { 'Content-Type': 'application/json' }
});
Content-Type: application/json
@unknwon
Copy link
Contributor

unknwon commented Oct 17, 2018

Hi,

Based on the logic of go-macaron/binding, as long as your content type contains "json", it works:

https://github.com/go-macaron/binding/blob/ac54ee249c27dca7e76fad851a4a04b73bd1b183/binding.go#L50-L52

If you're using a proxy, it is possible that it modifies the header (i.e. Content-Type) before passing to the backend (i.e. your app built with Macaron).

Can you provide more context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants