@@ -19,7 +19,7 @@ public static class HttpContentJsonExtensions
1919 Debug . Assert ( content . Headers . ContentType != null ) ;
2020 Encoding ? sourceEncoding = JsonContent . GetEncoding ( content . Headers . ContentType . CharSet ) ;
2121
22- return ReadFromJsonAsyncCore ( content , type , sourceEncoding , options ?? JsonContent . DefaultSerializerOptions , cancellationToken ) ;
22+ return ReadFromJsonAsyncCore ( content , type , sourceEncoding , options , cancellationToken ) ;
2323 }
2424
2525 public static Task < T > ReadFromJsonAsync < T > ( this HttpContent content , JsonSerializerOptions ? options = null , CancellationToken cancellationToken = default )
@@ -28,7 +28,7 @@ public static Task<T> ReadFromJsonAsync<T>(this HttpContent content, JsonSeriali
2828 Debug . Assert ( content . Headers . ContentType != null ) ;
2929 Encoding ? sourceEncoding = JsonContent . GetEncoding ( content . Headers . ContentType . CharSet ) ;
3030
31- return ReadFromJsonAsyncCore < T > ( content , sourceEncoding , options ?? JsonContent . DefaultSerializerOptions , cancellationToken ) ;
31+ return ReadFromJsonAsyncCore < T > ( content , sourceEncoding , options , cancellationToken ) ;
3232 }
3333
3434 private static async Task < object ? > ReadFromJsonAsyncCore ( HttpContent content , Type type , Encoding ? sourceEncoding , JsonSerializerOptions ? options , CancellationToken cancellationToken )
@@ -43,7 +43,7 @@ public static Task<T> ReadFromJsonAsync<T>(this HttpContent content, JsonSeriali
4343
4444 using ( contentStream )
4545 {
46- return await JsonSerializer . DeserializeAsync ( contentStream , type , options , cancellationToken ) . ConfigureAwait ( false ) ;
46+ return await JsonSerializer . DeserializeAsync ( contentStream , type , options ?? JsonContent . s_defaultSerializerOptions , cancellationToken ) . ConfigureAwait ( false ) ;
4747 }
4848 }
4949
@@ -59,7 +59,7 @@ private static async Task<T> ReadFromJsonAsyncCore<T>(HttpContent content, Encod
5959
6060 using ( contentStream )
6161 {
62- return await JsonSerializer . DeserializeAsync < T > ( contentStream , options , cancellationToken ) . ConfigureAwait ( false ) ;
62+ return await JsonSerializer . DeserializeAsync < T > ( contentStream , options ?? JsonContent . s_defaultSerializerOptions , cancellationToken ) . ConfigureAwait ( false ) ;
6363 }
6464 }
6565
0 commit comments