Skip to content

Commit

Permalink
A few more updates from peer review, Eirik's nits.
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Jul 24, 2023
1 parent deb2409 commit ad03a32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public static partial class HttpClientJsonExtensions
{
options ??= JsonSerializerOptions.Default;
options.MakeReadOnly();

var jsonTypeInfo = (JsonTypeInfo<TValue>)options.GetTypeInfo(typeof(TValue));

return FromJsonStreamAsyncCore(client, requestUri, jsonTypeInfo, cancellationToken);
Expand All @@ -161,13 +162,13 @@ public static partial class HttpClientJsonExtensions
JsonTypeInfo<TValue> jsonTypeInfo,
[EnumeratorCancellation] CancellationToken cancellationToken)
{
using HttpResponseMessage response = await s_getAsync(client, requestUri, cancellationToken)
Debug.Assert(client.MaxResponseContentBufferSize is > 0 and <= int.MaxValue);

using HttpResponseMessage response = await client.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead, cancellationToken)
.ConfigureAwait(false);

response.EnsureSuccessStatusCode();

Debug.Assert(client.MaxResponseContentBufferSize is > 0 and <= int.MaxValue);

using Stream contentStream = await HttpContentJsonExtensions.GetContentStreamAsync(
response.Content, cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public static partial class HttpContentJsonExtensions
CancellationToken cancellationToken)
{
options ??= JsonSerializerOptions.Default;
options.MakeReadOnly();

var jsonTypeInfo = (JsonTypeInfo<TValue>)options.GetTypeInfo(typeof(TValue));

return ReadFromJsonAsAsyncEnumerableCore(content, jsonTypeInfo, cancellationToken);
Expand Down

0 comments on commit ad03a32

Please sign in to comment.