This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Exception thrown for empty 204 HTTP response #9532
Closed
Description
I just upgraded to AngularJS 1.3.0-rc5 and I'm seeing an exception when $http attempts to handle a REST call response which returns a 204 status code with an empty entity (basically an empty string):
SyntaxError: Unexpected end of input
at Object.parse (native)
at fromJson (https://localhost:3443/bower_components/angular/angular.js:1103:14)
at defaultHttpResponseTransform (https://localhost:3443/bower_components/angular/angular.js:8319:18)
at https://localhost:3443/bower_components/angular/angular.js:8264:12
at forEach (https://localhost:3443/bower_components/angular/angular.js:335:20)
at transformData (https://localhost:3443/bower_components/angular/angular.js:8263:3)
at transformResponse (https://localhost:3443/bower_components/angular/angular.js:8953:17)
at processQueue (https://localhost:3443/bower_components/angular/angular.js:12642:27)
at https://localhost:3443/bower_components/angular/angular.js:12658:27
at Scope.$get.Scope.$eval (https://localhost:3443/bower_components/angular/angular.js:13851:28)
It looks like the response handling logic was changed so that setting a content type of "application/json" now properly attempts to parse the response as JSON every time. However, if the response is empty the JSON.parse() call fails. I wonder if perhaps a return code of 204 might need some special handling which interprets the returned data as undefined or null and does not attempt to parse the response entity.