Skip to content

Commit

Permalink
No need for the length limit read stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Jul 24, 2023
1 parent ad03a32 commit c99e708
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,10 @@ public static partial class HttpClientJsonExtensions
using Stream contentStream = await HttpContentJsonExtensions.GetContentStreamAsync(
response.Content, cancellationToken).ConfigureAwait(false);

using LengthLimitReadStream readStream = new(contentStream, (int)client.MaxResponseContentBufferSize);

await foreach (TValue? value in JsonSerializer.DeserializeAsyncEnumerable<TValue>(
readStream, jsonTypeInfo, cancellationToken).ConfigureAwait(false))
contentStream, jsonTypeInfo, cancellationToken).ConfigureAwait(false))
{
yield return value;

readStream.ResetCount();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ internal static void ThrowExceededBufferLimit(int limit)
throw new HttpRequestException(SR.Format(SR.net_http_content_buffersize_exceeded, limit));
}

internal void ResetCount() => _remainingLength = _lengthLimit;

public override bool CanRead => _innerStream.CanRead;
public override bool CanSeek => _innerStream.CanSeek;
public override bool CanWrite => false;
Expand Down

0 comments on commit c99e708

Please sign in to comment.