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

Respect content type negotiation #15

Closed
wants to merge 4 commits into from

Conversation

PhilippMi
Copy link
Contributor

Use the following rules to determine the response data type

  1. Use options.dataType if present
  2. Try to parse from the response content type header
  3. Try to parse from the request accept header

Previously, only the first accept header MIME type was taken into account.

fixes #10

Use the following rules to determine the response data type
1. Use options.dataType if present
2. Try to parse from the response content type header
3. Try to parse from the request accept header

Previously, only the first accept header MIME type was taken into
account.
data = xhr.responseXML;
break;
case 'json':
if (xhr.responseText !== '') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this line for? I think invalid JSON should throw, so the dev can fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akre54
Copy link
Owner

akre54 commented Mar 16, 2016

Can you look into the test failures and add some tests? This looks great, thanks.

@PhilippMi PhilippMi closed this Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse JSON based on accept header instead of content-type
2 participants