jonsamwell / angular-http-batcher

Enables HTTP batch request with AngularJS
MIT License
96 stars 28 forks source link

SyntaxError: Unexpected end of input #10

Closed pandarun closed 9 years ago

pandarun commented 9 years ago

Hi,

Thank you for the great module!

I think I've found a possible bug:

SyntaxError: Unexpected end of input at Object.parse (native) at Object.fromJson (http://localhost:8080/bower_components/angular/angular.js:1066:14) at angular.module.factory.convertDataToCorrectType (http://localhost:8080/bower_components/angular-http-batcher/dist/angular-http-batch.js:234:40) at Object.angular.module.factory.process (http://localhost:8080/bower_components/angular-http-batcher/dist/angular-http-batch.js:297:43) at http://localhost:8080/bower_components/angular-http-batcher/dist/angular-http-batch.js:377:48 at processQueue (http://localhost:8080/bower_components/angular/angular.js:13175:27) at http://localhost:8080/bower_components/angular/angular.js:13191:27 at Scope.$get.Scope.$eval (http://localhost:8080/bower_components/angular/angular.js:14388:28) at Scope.$get.Scope.$digest (http://localhost:8080/bower_components/angular/angular.js:14204:31) at Scope.$digest (http://localhost:8080/bower_components/ng-stats/dist/ng-stats.js:48:17)

Possible fix:

replace regex template regex = new RegExp('--.*--', 'i');
with regex = new RegExp('--[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}--', 'i');

line 289: angular-http-batch.js;

Web Api response

--31fcc127-a593-4e1d-86f3-57e45375848f Content-Type: application/http; msgtype=response

HTTP/1.1 200 OK Cache-Control: no-cache Content-Type: application/json; charset=utf-8

{"inlineCount":35} --31fcc127-a593-4e1d-86f3-57e45375848f Content-Type: application/http; msgtype=response

HTTP/1.1 200 OK Cache-Control: no-cache Content-Type: application/json; charset=utf-8

{"results":[{BusinessDescription":"Some text here\r--------------------------------------------------------------------------------------------------------------------------\r}],"inlineCount":35} --31fcc127-a593-4e1d-86f3-57e45375848f--

jonsamwell commented 9 years ago

Hi!

This is a good spot. I think it is a little more complicated than checking for a guid via regex. Microsoft seem to like guids as boundary separators but other provides use nonces, timestamps etc. I think the code needs to determine the boundary marker and compile a regex based on that. It shouldn't be to hard. I'll try and have a look this weekend.

Thanks,

Jon

jonsamwell commented 9 years ago

Sorry for the delay. This is now fixed in V1.7.0

Let me know if you are still getting any issues.