Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Detect JSON response by content-type header #2973

Closed
e-oz opened this issue Jun 15, 2013 · 6 comments
Closed

Detect JSON response by content-type header #2973

e-oz opened this issue Jun 15, 2013 · 6 comments

Comments

@e-oz
Copy link

e-oz commented Jun 15, 2013

Hello. In documentation to $http we can find:
If JSON response is detected, deserialize it using a JSON parser.
Please, don't ignore content-type header of response.
If server responds "string" (exactly with quotes) and content-type of response is JSON, $http.get().success() function should receive string without quotes, because data should be deserialized from JSON.

@e-oz
Copy link
Author

e-oz commented Jan 13, 2014

Please, give your attention. I think it's 1-2 lines in code to fix it, but behavior will be much more perfect.

@caitp
Copy link
Contributor

caitp commented Jan 13, 2014

I'm working on a patch for this right now. I'm afraid it is quite a bit more complicated than a 1-2 line fix, but it is being worked on :(

@e-oz
Copy link
Author

e-oz commented Jan 13, 2014

Wow! Thank you very much!

caitp added a commit to caitp/angular.js that referenced this issue Jan 13, 2014
The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
caitp added a commit to caitp/angular.js that referenced this issue Jan 13, 2014
…son'

The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
caitp added a commit to caitp/angular.js that referenced this issue Jan 13, 2014
…son'

The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
caitp added a commit to caitp/angular.js that referenced this issue Jan 13, 2014
…son'

The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
caitp added a commit to caitp/angular.js that referenced this issue Jan 13, 2014
…son'

The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
caitp added a commit to caitp/angular.js that referenced this issue Jan 13, 2014
…son'

The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
caitp added a commit to caitp/angular.js that referenced this issue Jan 13, 2014
…son'

The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
caitp added a commit to caitp/angular.js that referenced this issue Jan 14, 2014
…son'

The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
caitp added a commit to caitp/angular.js that referenced this issue Jan 14, 2014
…son'

The default behaviour breaks a wide variety of custom interpolation
markers. Even if the JSON text regexps were strengthened to closer
match the standard JSON format, it would still limit the possibilities
of different custom interpolation markers.

Instead, $http will no longer parse JSON if the response Content-Type header
does not include the term 'json', or if the $templateCache is used. For
inline templates, use the `content-type="json"` attribute to ensure that
inline JSON templates are parsed.

BREAKING CHANGE: Previously, responses would be parsed as JSON if their
content looked vaguely like JSON. Now, they are only parsed as JSON if their
Content-Type response header contains the term 'json', and if they are not
coming from the $templateCache.

Closes angular#5756
Closes angular#2973
@ashleygwilliams ashleygwilliams added this to the 1.3.x milestone Feb 21, 2014
@ashleygwilliams
Copy link

adding this issue to 1.3.x because the PR is in 1.3.x.

@caitp caitp self-assigned this Feb 21, 2014
@btford btford removed the gh: issue label Aug 20, 2014
IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Oct 2, 2014
…mitives

When server responds with Content-Type header set to application/json we now properly parse the response as JSON

Closes angular#2973
@e-oz
Copy link
Author

e-oz commented Oct 4, 2014

thank you!

@hoeni
Copy link

hoeni commented Oct 15, 2014

This change seems to break the angular-file-upload module (see nervgh/angular-file-upload#272)

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