mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 12:05:46 +08:00
fix($httpBackend): set headers with falsy values
This is a breaking change. To migrate to the new behavior, delete or set headers to `undefined` to avoid having them sent. To restore the old behavior, override `$httpBackendProvider` with the old implementation. Closes #2984
This commit is contained in:
@@ -101,6 +101,22 @@ describe('$httpBackend', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should set requested headers even if they have falsy values', function() {
|
||||
$backend('POST', 'URL', null, noop, {
|
||||
'X-header1': 0,
|
||||
'X-header2': '',
|
||||
'X-header3': false,
|
||||
'X-header4': undefined
|
||||
});
|
||||
|
||||
xhr = MockXhr.$$lastInstance;
|
||||
|
||||
expect(xhr.$$reqHeaders).toEqual({
|
||||
'X-header1': 0,
|
||||
'X-header2': '',
|
||||
'X-header3': false
|
||||
});
|
||||
});
|
||||
|
||||
it('should abort request on timeout', function() {
|
||||
callback.andCallFake(function(status, response) {
|
||||
@@ -388,6 +404,7 @@ describe('$httpBackend', function() {
|
||||
expect(callback).toHaveBeenCalled();
|
||||
expect(callback.mostRecentCall.args[0]).toBe(404);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user