From e7e3aef8289c2af3cc9e01fb3509ceaab0d712a0 Mon Sep 17 00:00:00 2001 From: Fred Sauer Date: Wed, 17 Oct 2012 10:12:51 -0700 Subject: [PATCH] Workaround missing HTTP response headers for CORS requests See https://github.com/angular/angular.js/issues/1468 See https://bugzilla.mozilla.org/show_bug.cgi?id=608735 --- blissful.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/blissful.js b/blissful.js index 5e9faa0..c0ca750 100644 --- a/blissful.js +++ b/blissful.js @@ -266,8 +266,6 @@ function ProjectController($scope, $http, $resource, $filter) { return false; }; - var noTransform = function(data) { return data; }; - $scope.select = function(i) { $scope.save(function() { _select(i) @@ -284,16 +282,24 @@ function ProjectController($scope, $http, $resource, $filter) { }); } + var noJsonTransform = function(data) { return data; }; + var _select = function(i) { $scope.currentIndex = i; url = '//' + $scope.config.BLISS_USER_CONTENT_HOST + document.location.pathname + 'getfile/' + encodeURI($scope.currentFilename()); - $http.get(url, {transformResponse: noTransform}) + $http.get(url, {transformResponse: noJsonTransform}) .success(function(data, status, headers, config) { // e.g. 'text/html; charset=UTF-8' var mime_type = headers('Content-Type'); + // Workaround missing HTTP response headers for CORS requests + // See https://github.com/angular/angular.js/issues/1468 + // See https://bugzilla.mozilla.org/show_bug.cgi?id=608735 + if (!mime_type) { + mime_type = 'application/octet-stream'; + } // strip '; charset=...' mime_type = mime_type.replace(/ ?;.*/, ''); if (/^image\//.test(mime_type)) {