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

Body is always JSON encoded, even with bodyBuilder set #108

Closed
marnusw opened this issue May 11, 2018 · 2 comments
Closed

Body is always JSON encoded, even with bodyBuilder set #108

marnusw opened this issue May 11, 2018 · 2 comments

Comments

@marnusw
Copy link
Contributor

marnusw commented May 11, 2018

I think this issue can be viewed as a sibling to #96 and #107.

I noticed that field normalization and JSON encoding is done after calling bodyBuilder. This is contrary to the documentation which states "...or encode the body in some format other than JSON." I'm sure JSON will be used in 99% of the time which is why this hasn't been reported yet, but it seems this should be corrected or the documentation should be changed if it's not a worthwhile feature.

I actually noticed this when investigating why the Content-Type header is set to html instead of application/json using the default body builder. (I know it can be overridden in various ways, but if the link changes the body encoding I feel it should also change the header.) This is the actual issue I wanted to point out, and one that I will address in a PR, but I think when that is done it might be good to resolve the above in full.

If I have time I might also look at inspecting the Content-Type of the response before JSON decoding, and maybe if the response body is empty one could just return an empty object which might solve #107. I'll investigate and see whether that works.

@paulpdaniels
Copy link
Contributor

@marnusw have you seen #103 ?

@marnusw
Copy link
Contributor Author

marnusw commented May 11, 2018

I had not. I only looked through the issues, my mistake. I'll close this and add some comments there.

@marnusw marnusw closed this as completed May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants