File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,20 @@ describe('Observable.ajax', () => {
141
141
} ) ;
142
142
} ) ;
143
143
144
+ it ( 'should not set default Content-Type header when no body is sent' , ( ) => {
145
+ const obj : Rx . AjaxRequest = {
146
+ url : '/talk-to-me-goose' ,
147
+ method : 'GET'
148
+ } ;
149
+
150
+ Rx . Observable . ajax ( obj ) . subscribe ( ) ;
151
+
152
+ const request = MockXMLHttpRequest . mostRecent ;
153
+
154
+ expect ( request . url ) . to . equal ( '/talk-to-me-goose' ) ;
155
+ expect ( request . requestHeaders ) . to . not . have . keys ( 'Content-Type' ) ;
156
+ } ) ;
157
+
144
158
it ( 'should error if createXHR throws' , ( ) => {
145
159
let error ;
146
160
const obj = {
Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ export class AjaxSubscriber<T> extends Subscriber<Event> {
191
191
}
192
192
193
193
// ensure content type is set
194
- if ( ! ( 'Content-Type' in headers ) && ! ( root . FormData && request . body instanceof root . FormData ) ) {
194
+ if ( ! ( 'Content-Type' in headers ) && ! ( root . FormData && request . body instanceof root . FormData ) && typeof request . body !== 'undefined' ) {
195
195
headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded; charset=UTF-8' ;
196
196
}
197
197
You can’t perform that action at this time.
0 commit comments