@@ -312,15 +312,15 @@ suite('Request', function() {
312312 body : 'I work out' ,
313313 headers : {
314314 accept : 'application/json' ,
315- 'Content-Type ' : 'text/plain '
315+ 'X-Request-ID ' : '123 '
316316 }
317317 } )
318318 var request2 = new Request ( request1 , {
319319 headers : { 'x-test' : '42' }
320320 } )
321321
322322 assert . equal ( request2 . headers . get ( 'accept' ) , undefined )
323- assert . equal ( request2 . headers . get ( 'content-type ' ) , undefined )
323+ assert . equal ( request2 . headers . get ( 'x-request-id ' ) , undefined )
324324 assert . equal ( request2 . headers . get ( 'x-test' ) , '42' )
325325 } )
326326
@@ -356,6 +356,18 @@ suite('Request', function() {
356356 } )
357357 } )
358358
359+ test ( 'GET should not have implicit Content-Type' , function ( ) {
360+ var req = new Request ( 'https://fetch.spec.whatwg.org/' )
361+ assert . equal ( req . headers . get ( 'content-type' ) , undefined )
362+ } )
363+
364+ test ( 'POST with blank body should not have implicit Content-Type' , function ( ) {
365+ var req = new Request ( 'https://fetch.spec.whatwg.org/' , {
366+ method : 'post'
367+ } )
368+ assert . equal ( req . headers . get ( 'content-type' ) , undefined )
369+ } )
370+
359371 test ( 'construct with string body sets Content-Type header' , function ( ) {
360372 var req = new Request ( 'https://fetch.spec.whatwg.org/' , {
361373 method : 'post' ,
@@ -365,25 +377,33 @@ suite('Request', function() {
365377 assert . equal ( req . headers . get ( 'content-type' ) , 'text/plain;charset=UTF-8' )
366378 } )
367379
368- ; ( Request . prototype . blob ? test : test . skip ) ( 'construct with Blob body and type sets Content-Type header' , function ( ) {
380+ featureDependent ( test , support . blob , 'construct with Blob body and type sets Content-Type header' , function ( ) {
369381 var req = new Request ( 'https://fetch.spec.whatwg.org/' , {
370382 method : 'post' ,
371- body : new Blob ( [ 'test' ] , { type : 'text/plain ' } ) ,
383+ body : new Blob ( [ 'test' ] , { type : 'image/png ' } )
372384 } )
373385
374- assert . equal ( req . headers . get ( 'content-type' ) , 'text/plain ' )
386+ assert . equal ( req . headers . get ( 'content-type' ) , 'image/png ' )
375387 } )
376388
377389 test ( 'construct with body and explicit header uses header' , function ( ) {
378390 var req = new Request ( 'https://fetch.spec.whatwg.org/' , {
379391 method : 'post' ,
380- headers : {
381- 'Content-Type' : 'text/plain'
382- } ,
392+ headers : { 'Content-Type' : 'image/png' } ,
383393 body : 'I work out'
384394 } )
385395
386- assert . equal ( req . headers . get ( 'content-type' ) , 'text/plain' )
396+ assert . equal ( req . headers . get ( 'content-type' ) , 'image/png' )
397+ } )
398+
399+ featureDependent ( test , support . blob , 'construct with Blob body and explicit Content-Type header' , function ( ) {
400+ var req = new Request ( 'https://fetch.spec.whatwg.org/' , {
401+ method : 'post' ,
402+ headers : { 'Content-Type' : 'image/png' } ,
403+ body : new Blob ( [ 'test' ] , { type : 'text/plain' } )
404+ } )
405+
406+ assert . equal ( req . headers . get ( 'content-type' ) , 'image/png' )
387407 } )
388408
389409 test ( 'clone request' , function ( ) {
@@ -564,7 +584,7 @@ suite('Response', function() {
564584 assert . equal ( r . headers . get ( 'content-type' ) , 'text/plain;charset=UTF-8' )
565585 } )
566586
567- ; ( Response . prototype . blob ? test : test . skip ) ( 'construct with Blob body and type sets Content-Type header' , function ( ) {
587+ featureDependent ( test , support . blob , 'construct with Blob body and type sets Content-Type header' , function ( ) {
568588 var r = new Response ( new Blob ( [ 'test' ] , { type : 'text/plain' } ) )
569589 assert . equal ( r . headers . get ( 'content-type' ) , 'text/plain' )
570590 } )
0 commit comments