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

Why enforcing content-type? #27

Closed
ericholiveira opened this issue Mar 7, 2016 · 3 comments
Closed

Why enforcing content-type? #27

ericholiveira opened this issue Mar 7, 2016 · 3 comments

Comments

@ericholiveira
Copy link

First of all, congratz for the amazing lib.
Ive been trying it in a new project using play framework as the backend, the problem is, with the current gateways i cant send any post data because Mappersmith always concatenate "application/x-www-form-urlencoded; charset=UTF-8;" on the request, this way play cant understand that im trying to send an application/json (even if i put it in the headers rule).

So i basically had to copy/paste the gateway to make it stop enforcing the form content-type. This is obviously a bad solution, so do you have plans to stop enforcing this content-type? You may first check the user header options and only the user didnt add a Content-type then you can put it.

I can even do a PR if you dont have the time to do this.

Thanks

@tulios
Copy link
Owner

tulios commented Mar 7, 2016

Hi @ericholiveira, thanks for opening this issue. I agree with you, Mappersmith should always follow the user defined content-type. Currently, you can prevent Mappersmith from guessing the content type by setting the body attribute to something different than an object, example:

Client.Photo.save({
  category: 'family',
  body: JSON.stringify({year: 2015, tags: ['party', 'family']})
})

I will fix this and release a new version. Thanks for your input!

@ericholiveira
Copy link
Author

Great... ive tried like you said before opening this issue and what i got was a request with content-type "application/x-www-form-urlencoded; charset=UTF-8; application/json" , the body was sent correctly, as a json string, but the server could read because this wasnt an explicit application/json header.

Anyway, thx for the help :)

@tulios tulios closed this as completed in b36d265 Mar 7, 2016
@tulios
Copy link
Owner

tulios commented Mar 7, 2016

I released version 0.13.2 with this fix. Thanks for your input.

tulios pushed a commit that referenced this issue Jun 17, 2016
…as a “;” termination (closes #31)

PR #26 introduced this bug trying to solve issue #27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants