@@ -369,6 +369,15 @@ describe('fetch', () => {
369369 msw . http . get ( '/boom' , ( ) => {
370370 return new msw . HttpResponse ( null , { status : 500 } ) ;
371371 } ) ,
372+ msw . http . get ( '/null-body-204' , ( ) => {
373+ return new msw . HttpResponse ( null , { status : 204 } ) ;
374+ } ) ,
375+ msw . http . get ( '/null-body-205' , ( ) => {
376+ return new msw . HttpResponse ( null , { status : 205 } ) ;
377+ } ) ,
378+ msw . http . get ( '/null-body-304' , ( ) => {
379+ return new msw . HttpResponse ( null , { status : 304 } ) ;
380+ } ) ,
372381 ] ,
373382 callback = ( ) => fetch ( '/api/status.json' ) ,
374383 config = { } ,
@@ -391,6 +400,40 @@ describe('fetch', () => {
391400 return { rootSpan, response } ;
392401 } ;
393402
403+ describe ( 'null-bodied response' , ( ) => {
404+ // https://chromium.googlesource.com/chromium/src/+/ac85ca2a9cb8c76a37f9d7a6c611c24114f1f05d/third_party/WebKit/Source/core/fetch/Response.cpp#106
405+ it ( '204 (No Content) will correctly end the span' , async ( ) => {
406+ await tracedFetch ( {
407+ callback : ( ) => fetch ( '/null-body-204' ) ,
408+ } ) ;
409+ assert . strictEqual ( exportedSpans . length , 1 ) ;
410+ assert . strictEqual (
411+ exportedSpans [ 0 ] . attributes [ ATTR_HTTP_STATUS_CODE ] ,
412+ 204
413+ ) ;
414+ } ) ;
415+ it ( '205 (Reset Content) will correctly end the span' , async ( ) => {
416+ await tracedFetch ( {
417+ callback : ( ) => fetch ( '/null-body-205' ) ,
418+ } ) ;
419+ assert . strictEqual ( exportedSpans . length , 1 ) ;
420+ assert . strictEqual (
421+ exportedSpans [ 0 ] . attributes [ ATTR_HTTP_STATUS_CODE ] ,
422+ 205
423+ ) ;
424+ } ) ;
425+ it ( '304 (Not Modified) will correctly end the span' , async ( ) => {
426+ await tracedFetch ( {
427+ callback : ( ) => fetch ( '/null-body-304' ) ,
428+ } ) ;
429+ assert . strictEqual ( exportedSpans . length , 1 ) ;
430+ assert . strictEqual (
431+ exportedSpans [ 0 ] . attributes [ ATTR_HTTP_STATUS_CODE ] ,
432+ 304
433+ ) ;
434+ } ) ;
435+ } ) ;
436+
394437 describe ( 'simple request' , ( ) => {
395438 let rootSpan : api . Span | undefined ;
396439 let response : Response | undefined ;
0 commit comments