File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -322,9 +322,9 @@ export class HttpRequest<T> {
322322 if ( this . body instanceof HttpParams ) {
323323 return 'application/x-www-form-urlencoded;charset=UTF-8' ;
324324 }
325- // Arrays, objects, and numbers will be encoded as JSON.
325+ // Arrays, objects, boolean and numbers will be encoded as JSON.
326326 if ( typeof this . body === 'object' || typeof this . body === 'number' ||
327- Array . isArray ( this . body ) ) {
327+ typeof this . body === 'boolean' ) {
328328 return 'application/json' ;
329329 }
330330 // No type could be inferred.
Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ const TEST_STRING = `I'm a body!`;
129129 const req = baseReq . clone ( { body : { data : 'test data' } } ) ;
130130 expect ( req . detectContentTypeHeader ( ) ) . toBe ( 'application/json' ) ;
131131 } ) ;
132+ it ( 'handles boolean as json' , ( ) => {
133+ const req = baseReq . clone ( { body : true } ) ;
134+ expect ( req . detectContentTypeHeader ( ) ) . toBe ( 'application/json' ) ;
135+ } ) ;
132136 } ) ;
133137 describe ( 'body serialization' , ( ) => {
134138 const baseReq = new HttpRequest ( 'POST' , '/test' , null ) ;
You can’t perform that action at this time.
0 commit comments