diff options
| author | Caio Cunha | 2013-06-19 21:30:28 +0100 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-06-19 21:30:59 +0100 |
| commit | 53359d549e364759d5b382c229f7d326799bf418 (patch) | |
| tree | 6495e53887970b63a90511a15089d7465e2ea6c1 /test | |
| parent | f1b94b4b599ab701bc75b55bbbbb73c5ef329a93 (diff) | |
| download | angular.js-53359d549e364759d5b382c229f7d326799bf418.tar.bz2 | |
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.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/httpSpec.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index 4ddb3661..8f2642f3 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -717,6 +717,21 @@ describe('$http', function() { $httpBackend.flush(); }); + 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 set XSRF cookie for cross-domain requests', inject(function($browser) { $browser.cookies('XSRF-TOKEN', 'secret'); $browser.url('http://host.com/base'); @@ -734,7 +749,12 @@ describe('$http', function() { return !headers.hasOwnProperty('Content-Type'); }).respond(''); + $httpBackend.expect('POST', '/url2', undefined, function(headers) { + return !headers.hasOwnProperty('content-type'); + }).respond(''); + $http({url: '/url', method: 'POST'}); + $http({url: '/url2', method: 'POST', headers: {'content-type': 'Rewritten'}}); $httpBackend.flush(); }); |
