aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVojta Jina2011-05-03 09:40:39 +0200
committerIgor Minar2011-05-19 09:43:56 -0700
commit9f56af9c15e1096033c91c2619f7f7f0115d0032 (patch)
tree1818ce436a4ea4b80189af5cc28f83dc1e28904b /test
parentc5f0342ad87ba91d43e8b99bfc82039cdbf998a2 (diff)
downloadangular.js-9f56af9c15e1096033c91c2619f7f7f0115d0032.tar.bz2
XHR should add Content-type header only for POST
Sending Content-type header causes JSTD (Jetty) proxy to change GET methods into POST.
Diffstat (limited to 'test')
-rw-r--r--test/BrowserSpecs.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js
index 3b5a9ba0..5a18e1b9 100644
--- a/test/BrowserSpecs.js
+++ b/test/BrowserSpecs.js
@@ -101,16 +101,15 @@ describe('browser', function(){
it('should set headers for all requests', function(){
var code, response, headers = {};
- browser.xhr('METHOD', 'URL', 'POST', function(c,r){
+ browser.xhr('GET', 'URL', 'POST', function(c,r){
code = c;
response = r;
}, {'X-header': 'value'});
- expect(xhr.method).toEqual('METHOD');
+ expect(xhr.method).toEqual('GET');
expect(xhr.url).toEqual('URL');
expect(xhr.post).toEqual('POST');
expect(xhr.headers).toEqual({
- "Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json, text/plain, */*",
"X-Requested-With": "XMLHttpRequest",
"X-header":"value"
@@ -124,9 +123,27 @@ describe('browser', function(){
expect(code).toEqual(202);
expect(response).toEqual('RESPONSE');
});
+
+ it('should not set Content-type header for GET requests', function() {
+ browser.xhr('GET', 'URL', 'POST-DATA', function(c, r) {});
- });
+ expect(xhr.headers['Content-Type']).not.toBeDefined();
+ });
+
+ it('should set Content-type header for POST requests', function() {
+ browser.xhr('POST', 'URL', 'POST-DATA', function(c, r) {});
+
+ expect(xhr.headers['Content-Type']).toBeDefined();
+ expect(xhr.headers['Content-Type']).toEqual('application/x-www-form-urlencoded');
+ });
+
+ it('should set default headers for custom methods', function() {
+ browser.xhr('CUSTOM', 'URL', 'POST-DATA', function(c, r) {});
+ expect(xhr.headers['Accept']).toEqual('application/json, text/plain, */*');
+ expect(xhr.headers['X-Requested-With']).toEqual('XMLHttpRequest');
+ });
+ });
describe('defer', function() {
it('should execute fn asynchroniously via setTimeout', function() {