File tree Expand file tree Collapse file tree 4 files changed +29
-2
lines changed
test/unit/lib/http_adapter Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1616 AngularAdapter . prototype . post = function ( req ) {
1717 var headers = {
1818 'x-tagged-client-id' : req . clientId ,
19- 'x-tagged-client-url' : this . _$window . location
19+ 'x-tagged-client-url' : this . _$window . location ,
20+ 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
2021 } ;
2122 return this . _$http . post ( req . url , req . body , {
2223 timeout : 10000 ,
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ Http.prototype.post = function(req) {
99 var headers = {
1010 Cookie : req . cookies || { } ,
1111 'x-tagged-client-id' : req . clientId ,
12- 'x-tagged-client-secret' : req . secret
12+ 'x-tagged-client-secret' : req . secret ,
13+ 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
1314 } ;
1415
1516 return this . _request . postAsync ( {
Original file line number Diff line number Diff line change @@ -81,6 +81,18 @@ describe('Angular Adapter', function() {
8181 this . $http . post . lastCall . args [ 2 ] . headers [ 'x-tagged-client-id' ] . should . equal ( clientId ) ;
8282 this . $http . post . lastCall . args [ 2 ] . headers [ 'x-tagged-client-url' ] . should . equal ( location ) ;
8383 } ) ;
84+
85+ it ( 'sets content-type header' , function ( ) {
86+ var url = 'http://example.com/foo' ;
87+ var body = 'post body' ;
88+ var expectedContentType = 'application/x-www-form-urlencoded; charset=UTF-8' ;
89+ this . adapter . post ( {
90+ url : url ,
91+ body : body
92+ } ) ;
93+ this . $http . post . calledOnce . should . be . true ;
94+ this . $http . post . lastCall . args [ 2 ] . headers . should . have . property ( 'Content-Type' , expectedContentType ) ;
95+ } ) ;
8496 } ) ;
8597
8698 describe ( 'getSessionToken' , function ( ) {
Original file line number Diff line number Diff line change @@ -70,6 +70,19 @@ describe('Node HTTP Adapter', function() {
7070 this . request . post . lastCall . args [ 0 ] . headers . should . have . property ( 'x-tagged-client-secret' , clientSecret ) ;
7171 } ) ;
7272
73+ it ( 'sets content-type header' , function ( ) {
74+ var expectedContentType = 'application/x-www-form-urlencoded; charset=UTF-8' ;
75+ var url = 'http://example.com/foo' ;
76+ var body = 'post body' ;
77+ this . http . post ( {
78+ url : url ,
79+ body : body
80+ } ) ;
81+ this . request . post . calledOnce . should . be . true ;
82+ this . request . post . lastCall . args [ 0 ] . should . have . property ( 'headers' ) ;
83+ this . request . post . lastCall . args [ 0 ] . headers . should . have . property ( 'Content-Type' , expectedContentType ) ;
84+ } ) ;
85+
7386 it ( 'resolves with response' , function ( ) {
7487 var expectedBody = 'expected body' ;
7588 var result = this . http . post ( {
You can’t perform that action at this time.
0 commit comments