AngularJS resource hacked based on this issue https://github.com/angular/angular.js/pull/1364