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

Content-Type: "application/json; charset=utf-8" #39

Closed
ghost opened this issue Jun 9, 2014 · 2 comments
Closed

Content-Type: "application/json; charset=utf-8" #39

ghost opened this issue Jun 9, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 9, 2014

We have modified this part of your code (node-rest-client.js):


296 "isJSON":function(content){
297 content = content.replace(' ', '');


because our restful server replies with a space between chars ';' and 'charset ....':
"application/json; charset=utf-8"
but your code expects:
"application/json;charset=utf-8"

In general your code does not support spaces in the 'Content-Type' response header.

@aacerox
Copy link
Owner

aacerox commented Jun 9, 2014

Hi
You don't need to modify the code to achive what you want because you can set a custom content-type definition for JSON or XML when you initialize the client.

Please refer to issues #12 or #17 or to client documentation https://github.com/aacerox/node-rest-client#options-parameters

Thanks.

@ethanjcohen
Copy link

I'm having the same issue, and I made the same modification to my version of the code.

I'd suggest using .indexOf('application/json') > -1 in your code, rather than doing an exact comparison. This method will support more implementations by default.

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