mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
fix($http): ensure case-insens. header overriding
If user send content-type header, both content-type and default Content-Type headers were sent. Now default header overriding is case-insensitive.
This commit is contained in:
committed by
Pete Bacon Darwin
parent
1b234cb7af
commit
25d9f5a804
@@ -430,6 +430,21 @@ describe('$http', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should override default headers with custom in a case insensitive manner', function() {
|
||||
$httpBackend.expect('POST', '/url', 'messageBody', function(headers) {
|
||||
return headers['accept'] == 'Rewritten' &&
|
||||
headers['content-type'] == 'Content-Type Rewritten' &&
|
||||
headers['Accept'] === undefined &&
|
||||
headers['Content-Type'] === undefined;
|
||||
}).respond('');
|
||||
|
||||
$http({url: '/url', method: 'POST', data: 'messageBody', headers: {
|
||||
'accept': 'Rewritten',
|
||||
'content-type': 'Content-Type Rewritten'
|
||||
}});
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should not send Content-Type header if request data/body is undefined', function() {
|
||||
$httpBackend.expect('POST', '/url', undefined, function(headers) {
|
||||
return !headers.hasOwnProperty('Content-Type');
|
||||
|
||||
Reference in New Issue
Block a user