mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-03 22:44:00 +08:00
@@ -64,6 +64,7 @@
|
||||
"isWindow": false,
|
||||
"isScope": false,
|
||||
"isFile": false,
|
||||
"isBlob": false,
|
||||
"isBoolean": false,
|
||||
"trim": false,
|
||||
"isElement": false,
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
-isWindow,
|
||||
-isScope,
|
||||
-isFile,
|
||||
-isBlob,
|
||||
-isBoolean,
|
||||
-trim,
|
||||
-isElement,
|
||||
@@ -566,6 +567,11 @@ function isFile(obj) {
|
||||
}
|
||||
|
||||
|
||||
function isBlob(obj) {
|
||||
return toString.call(obj) === '[object Blob]';
|
||||
}
|
||||
|
||||
|
||||
function isBoolean(value) {
|
||||
return typeof value === 'boolean';
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ function $HttpProvider() {
|
||||
|
||||
// transform outgoing request data
|
||||
transformRequest: [function(d) {
|
||||
return isObject(d) && !isFile(d) ? toJson(d) : d;
|
||||
return isObject(d) && !isFile(d) && !isBlob(d) ? toJson(d) : d;
|
||||
}],
|
||||
|
||||
// default headers
|
||||
|
||||
@@ -989,6 +989,16 @@ describe('$http', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should ignore Blob objects', function () {
|
||||
if (!window.Blob) return;
|
||||
|
||||
var blob = new Blob(['blob!'], { type: 'text/plain' });
|
||||
|
||||
$httpBackend.expect('POST', '/url', '[object Blob]').respond('');
|
||||
$http({ method: 'POST', url: '/url', data: blob });
|
||||
});
|
||||
|
||||
|
||||
it('should have access to request headers', function() {
|
||||
$httpBackend.expect('POST', '/url', 'header1').respond(200);
|
||||
$http.post('/url', 'req', {
|
||||
|
||||
Reference in New Issue
Block a user