@@ -576,6 +576,31 @@ public void TestObjectToTypedData_WhenBodyIsNotJsonAndContentTypeIsSpecified_Add
576576 Assert . Equal ( "text/html" , input . ToTypedData ( ) . Http . Headers [ "content-type" ] ) ;
577577 }
578578
579+ [ Theory ]
580+ [ InlineData ( null , HttpStatusCode . OK ) ]
581+ [ InlineData ( "text/plain" , HttpStatusCode . OK ) ]
582+ [ InlineData ( "application/json" , HttpStatusCode . OK ) ]
583+ [ InlineData ( "anything/else" , HttpStatusCode . OK ) ]
584+ [ InlineData ( null , HttpStatusCode . NoContent ) ]
585+ [ InlineData ( "text/plain" , HttpStatusCode . NoContent ) ]
586+ [ InlineData ( "application/json" , HttpStatusCode . NoContent ) ]
587+ [ InlineData ( "anything/else" , HttpStatusCode . NoContent ) ]
588+ public void TestObjectToTypedData_WhenBodyIsNull ( string contentType , HttpStatusCode statusCode )
589+ {
590+ var input = new HttpResponseContext
591+ {
592+ Body = null ,
593+ ContentType = contentType ,
594+ StatusCode = statusCode ,
595+ } ;
596+
597+ var result = input . ToTypedData ( ) . Http ;
598+
599+ Assert . Equal ( string . Empty , result . Body . String ) ;
600+ var expectedContentType = contentType ?? "text/plain" ;
601+ Assert . Equal ( expectedContentType , result . Headers [ "content-type" ] ) ;
602+ }
603+
579604 [ Fact ]
580605 public void TestObjectToTypedDataInt ( )
581606 {
0 commit comments