aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Angular.js5
-rw-r--r--src/service/http.js2
-rw-r--r--test/service/httpSpec.js19
3 files changed, 25 insertions, 1 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 87c10e23..fec866f5 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -417,6 +417,11 @@ function isScope(obj) {
}
+function isFile(obj) {
+ return toString.apply(obj) === '[object File]';
+}
+
+
function isBoolean(value) {return typeof value == $boolean;}
function isTextNode(node) {return nodeName_(node) == '#text';}
diff --git a/src/service/http.js b/src/service/http.js
index 93d44eac..afaae2de 100644
--- a/src/service/http.js
+++ b/src/service/http.js
@@ -102,7 +102,7 @@ function $HttpProvider() {
// transform outgoing request data
transformRequest: function(d) {
- return isObject(d) ? toJson(d) : d;
+ return isObject(d) && !isFile(d) ? toJson(d) : d;
},
// default headers
diff --git a/test/service/httpSpec.js b/test/service/httpSpec.js
index ad376b5f..4c8471d8 100644
--- a/test/service/httpSpec.js
+++ b/test/service/httpSpec.js
@@ -564,6 +564,25 @@ describe('$http', function() {
$httpBackend.expect('POST', '/url', 'string-data').respond('');
$http({method: 'POST', url: '/url', data: 'string-data'});
});
+
+
+ it('should ignore File objects', function() {
+ var file = {
+ some: true,
+ // $httpBackend compares toJson values by default,
+ // we need to be sure it's not serialized into json string
+ test: function(actualValue) {
+ return this === actualValue;
+ }
+ };
+
+ // I'm really sorry for doing this :-D
+ // Unfortunatelly I don't know how to trick toString.apply(obj) comparison
+ spyOn(window, 'isFile').andReturn(true);
+
+ $httpBackend.expect('POST', '/some', file).respond('');
+ $http({method: 'POST', url: '/some', data: file});
+ });
});